From c2245e51a6fb8c0e69b741f677e506a966f5cc08 Mon Sep 17 00:00:00 2001 From: Werner Dietl Date: Mon, 26 Jun 2023 05:39:57 -0400 Subject: [PATCH 01/37] Basic Nullness Checker configuration --- build.gradle | 19 ++++++++++ .../org/key_project/util/lookup/Lookup.java | 38 ++++++++++++------- 2 files changed, 44 insertions(+), 13 deletions(-) diff --git a/build.gradle b/build.gradle index 322250e1696..6eba4615d0c 100644 --- a/build.gradle +++ b/build.gradle @@ -22,6 +22,9 @@ plugins { // Code formatting id "com.diffplug.spotless" version "6.16.0" + + // EISOP Checker Framework + id "org.checkerframework" version "0.6.28" } // Configure this project for use inside IntelliJ: @@ -62,6 +65,7 @@ subprojects { apply plugin: "com.diffplug.spotless" apply plugin: "checkstyle" apply plugin: "pmd" + apply plugin: "org.checkerframework" group = rootProject.group version = rootProject.version @@ -84,6 +88,10 @@ subprojects { //compile group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.12.0' implementation 'com.google.code.findbugs:jsr305:3.0.2' + compileOnly 'org.jspecify:jspecify:0.3.0' + compileOnly 'io.github.eisop:checker-qual:3.34.0-eisop1' + checkerFramework 'io.github.eisop:checker:3.34.0-eisop1' + testImplementation 'org.junit.jupiter:junit-jupiter-api:5.9.3' testImplementation 'org.junit.jupiter:junit-jupiter-params:5.9.3' testCompileOnly 'junit:junit:4.13.2' @@ -405,6 +413,17 @@ subprojects { } } + checkerFramework { + checkers = [ + "org.checkerframework.checker.nullness.NullnessChecker", + ] + extraJavacArgs = [ + "-AonlyDefs=^org\\.key_project\\.util\\.lookup", + "-Xmaxerrs", "10000", + "-Werror", + "-Aversion", + ] + } } task start { diff --git a/key.util/src/main/java/org/key_project/util/lookup/Lookup.java b/key.util/src/main/java/org/key_project/util/lookup/Lookup.java index aafa59e4fa5..441e91b69fa 100644 --- a/key.util/src/main/java/org/key_project/util/lookup/Lookup.java +++ b/key.util/src/main/java/org/key_project/util/lookup/Lookup.java @@ -7,6 +7,10 @@ import java.util.*; import java.util.stream.Collectors; +import org.checkerframework.checker.initialization.qual.Initialized; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; + /** * This class handles the management of services and implementations. *

@@ -19,10 +23,11 @@ * @author Alexander Weigl * @version 1 (15.03.19) */ +@NullMarked public class Lookup { - public static Lookup DEFAULT = new Lookup(); + public static final Lookup DEFAULT = new Lookup(); - private final Lookup parent; + private final @Nullable Lookup parent; /** * Registered services. The first service in the list is the default. @@ -43,10 +48,13 @@ public Lookup() { this(null); } - public Lookup(Lookup parent) { + public Lookup(@Nullable Lookup parent) { this.parent = parent; if (parent != null) { - parent.children.add(new WeakReference<>(this)); + @SuppressWarnings("nullness") // WeakReference to this + @Initialized + WeakReference weakthis = new WeakReference<>(this); + parent.children.add(weakthis); } } @@ -81,7 +89,7 @@ public Collection lookupAll(Class service) { * @param * @return */ - public T get(Class service) { + public T get(Class service) { List t = getList(service); if (t.isEmpty()) { if (parent != null) { @@ -132,7 +140,7 @@ public void dispose() { } } - public List getListeners(Class name) { + public List getListeners(Class name) { return propertyListener.computeIfAbsent(name, a -> new LinkedList<>()); } @@ -140,11 +148,11 @@ public void addChangeListener(LookupListener listener) { addChangeListener(ALL.class, listener); } - public void addChangeListener(Class name, LookupListener listener) { + public void addChangeListener(Class name, LookupListener listener) { getListeners(name).add(listener); } - public void removeChangeListener(Class name, LookupListener listener) { + public void removeChangeListener(Class name, LookupListener listener) { getListeners(name).remove(listener); } @@ -176,7 +184,7 @@ public void register(T o) { } @SuppressWarnings("unchecked") - private List getList(Class service) { + private List getList(Class service) { return (List) serviceMap.computeIfAbsent(service, (k -> new LinkedList<>())); } @@ -189,8 +197,10 @@ private List getList(Class service) { * @return * @throws InjectionException if non suitable constructors could be found. */ - @SuppressWarnings("unchecked") - public T createInstance(Class clazz) throws InjectionException { + @SuppressWarnings({ "unchecked", + "keyfor", "nullness", // KeyFor and type variable bounds + }) + public @Nullable T createInstance(Class clazz) throws InjectionException { for (Constructor ctor : clazz.getConstructors()) { if (ctor.getAnnotation(Inject.class) != null) { T instance = (T) tryToInject(ctor); @@ -208,13 +218,15 @@ public T createInstance(Class clazz) throws InjectionException { * @return * @throws InjectionException */ - protected T tryToInject(Constructor ctor) throws InjectionException { + protected @Nullable T tryToInject(Constructor ctor) throws InjectionException { List services = Arrays.stream(ctor.getParameterTypes()).map(this::get).collect(Collectors.toList()); if (services.stream().allMatch(Objects::nonNull)) { try { - return ctor.newInstance(services.toArray()); + @SuppressWarnings("nullness") // connection to allMatch lost + T res = ctor.newInstance(services.toArray()); + return res; } catch (InstantiationException | IllegalAccessException | InvocationTargetException e) { throw new InjectionException(e); From d1bc0a46aece6489ab928d391de21d1ffa3967cc Mon Sep 17 00:00:00 2001 From: Mattias Ulbrich Date: Mon, 26 Jun 2023 13:11:23 +0200 Subject: [PATCH 02/37] [small] merging 2 string util classes --- .../java/org/key_project/util/Strings.java | 41 ++++--------------- .../org/key_project/util/java/StringUtil.java | 41 +++++++++++++++++++ 2 files changed, 49 insertions(+), 33 deletions(-) diff --git a/key.util/src/main/java/org/key_project/util/Strings.java b/key.util/src/main/java/org/key_project/util/Strings.java index 8791a5065c0..5ec119e3513 100644 --- a/key.util/src/main/java/org/key_project/util/Strings.java +++ b/key.util/src/main/java/org/key_project/util/Strings.java @@ -1,7 +1,6 @@ package org.key_project.util; -import java.util.regex.Matcher; -import java.util.regex.Pattern; +import org.key_project.util.java.StringUtil; /** * Helper functions for {@link String}s @@ -11,43 +10,19 @@ */ public class Strings { /** - * Checks whether a string contains another one as a whole word (i.e., separated by whitespaces - * or a semicolon at the end). - * - * @param s string to search in - * @param word string to be searched for + * @deprecated This class has been merged with {@link org.key_project.util.java.StringUtil}. + * Call {@link org.key_project.util.java.StringUtil#containsWholeWord(String, String)} */ + @Deprecated public static boolean containsWholeWord(String s, String word) { - Pattern p = Pattern.compile("\\b" + word + "\\b"); - Matcher m = p.matcher(s); - return m.find(); - /* - * if (s == null || word == null) { return false; } int i = -1; final int wl = - * word.length(); while (true) { i = s.indexOf(word, i + 1); if (i < 0 || i >= s.length()) - * break; if (i == 0 || Character.isWhitespace(s.charAt(i - 1))) { if (i + wl == s.length() - * || Character.isWhitespace(s.charAt(i + wl)) || s.charAt(i + wl) == ';') { return true; } - * } } return false; - */ + return StringUtil.containsWholeWord(s, word); } - /** - * There are different kinds of JML markers. See Section 4.4 "Annotation markers" of the JML - * reference manual. - * - * @param comment - * @return + * @deprecated This class has been merged with {@link org.key_project.util.java.StringUtil}. + * Call {@link org.key_project.util.java.StringUtil#isJMLComment(String)} */ public static boolean isJMLComment(String comment) { - try { - return (comment.startsWith("/*@") || comment.startsWith("//@") - || comment.startsWith("/*+KeY@") || comment.startsWith("//+KeY@") - || (comment.startsWith("/*-") && !comment.startsWith("KeY", 3) - && comment.contains("@")) - || (comment.startsWith("//-") && !comment.startsWith("KeY", 3) - && comment.contains("@"))); - } catch (IndexOutOfBoundsException e) { - return false; - } + return StringUtil.isJMLComment(comment); } } diff --git a/key.util/src/main/java/org/key_project/util/java/StringUtil.java b/key.util/src/main/java/org/key_project/util/java/StringUtil.java index 1504183e04b..09b7652fc49 100644 --- a/key.util/src/main/java/org/key_project/util/java/StringUtil.java +++ b/key.util/src/main/java/org/key_project/util/java/StringUtil.java @@ -3,6 +3,7 @@ import java.util.Arrays; import java.util.Comparator; import java.util.function.Predicate; +import java.util.regex.Matcher; import java.util.regex.Pattern; import javax.annotation.Nonnull; import javax.swing.*; @@ -433,4 +434,44 @@ public static String trim(String text, String chars) { public static String replaceNewlines(String text, String with) { return NEWLINE_PATTERN.matcher(text).replaceAll(with); } + + /** + * Checks whether a string contains another one as a whole word (i.e., separated by whitespaces + * or a semicolon at the end). + * + * @param s string to search in + * @param word string to be searched for + */ + public static boolean containsWholeWord(String s, String word) { + Pattern p = Pattern.compile("\\b" + word + "\\b"); + Matcher m = p.matcher(s); + return m.find(); + /* + * if (s == null || word == null) { return false; } int i = -1; final int wl = + * word.length(); while (true) { i = s.indexOf(word, i + 1); if (i < 0 || i >= s.length()) + * break; if (i == 0 || Character.isWhitespace(s.charAt(i - 1))) { if (i + wl == s.length() + * || Character.isWhitespace(s.charAt(i + wl)) || s.charAt(i + wl) == ';') { return true; } + * } } return false; + */ + } + + /** + * There are different kinds of JML markers. See Section 4.4 "Annotation markers" of the JML + * reference manual. + * + * @param comment + * @return + */ + public static boolean isJMLComment(String comment) { + try { + return (comment.startsWith("/*@") || comment.startsWith("//@") + || comment.startsWith("/*+KeY@") || comment.startsWith("//+KeY@") + || (comment.startsWith("/*-") && !comment.startsWith("KeY", 3) + && comment.contains("@")) + || (comment.startsWith("//-") && !comment.startsWith("KeY", 3) + && comment.contains("@"))); + } catch (IndexOutOfBoundsException e) { + return false; + } + } } From 018e5fea1777deff98d526c9b856eaa9ab873527 Mon Sep 17 00:00:00 2001 From: Werner Dietl Date: Mon, 26 Jun 2023 07:22:45 -0400 Subject: [PATCH 03/37] Run spotlessApply, add missing Deprecated annotation --- key.util/src/main/java/org/key_project/util/Strings.java | 6 ++++-- .../src/main/java/org/key_project/util/java/StringUtil.java | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/key.util/src/main/java/org/key_project/util/Strings.java b/key.util/src/main/java/org/key_project/util/Strings.java index 5ec119e3513..55e292a1257 100644 --- a/key.util/src/main/java/org/key_project/util/Strings.java +++ b/key.util/src/main/java/org/key_project/util/Strings.java @@ -11,7 +11,8 @@ public class Strings { /** * @deprecated This class has been merged with {@link org.key_project.util.java.StringUtil}. - * Call {@link org.key_project.util.java.StringUtil#containsWholeWord(String, String)} + * Call + * {@link org.key_project.util.java.StringUtil#containsWholeWord(String, String)} */ @Deprecated public static boolean containsWholeWord(String s, String word) { @@ -20,8 +21,9 @@ public static boolean containsWholeWord(String s, String word) { /** * @deprecated This class has been merged with {@link org.key_project.util.java.StringUtil}. - * Call {@link org.key_project.util.java.StringUtil#isJMLComment(String)} + * Call {@link org.key_project.util.java.StringUtil#isJMLComment(String)} */ + @Deprecated public static boolean isJMLComment(String comment) { return StringUtil.isJMLComment(comment); } diff --git a/key.util/src/main/java/org/key_project/util/java/StringUtil.java b/key.util/src/main/java/org/key_project/util/java/StringUtil.java index 09b7652fc49..976dca45680 100644 --- a/key.util/src/main/java/org/key_project/util/java/StringUtil.java +++ b/key.util/src/main/java/org/key_project/util/java/StringUtil.java @@ -467,9 +467,9 @@ public static boolean isJMLComment(String comment) { return (comment.startsWith("/*@") || comment.startsWith("//@") || comment.startsWith("/*+KeY@") || comment.startsWith("//+KeY@") || (comment.startsWith("/*-") && !comment.startsWith("KeY", 3) - && comment.contains("@")) + && comment.contains("@")) || (comment.startsWith("//-") && !comment.startsWith("KeY", 3) - && comment.contains("@"))); + && comment.contains("@"))); } catch (IndexOutOfBoundsException e) { return false; } From 2cf9325a4ee61abdca2cc85a7132bec5785ec73e Mon Sep 17 00:00:00 2001 From: Werner Dietl Date: Mon, 26 Jun 2023 07:23:09 -0400 Subject: [PATCH 04/37] Add testComileOnly depencency --- build.gradle | 1 + 1 file changed, 1 insertion(+) diff --git a/build.gradle b/build.gradle index 6eba4615d0c..fa473fe1ce4 100644 --- a/build.gradle +++ b/build.gradle @@ -90,6 +90,7 @@ subprojects { compileOnly 'org.jspecify:jspecify:0.3.0' compileOnly 'io.github.eisop:checker-qual:3.34.0-eisop1' + testCompileOnly 'io.github.eisop:checker-qual:3.34.0-eisop1' checkerFramework 'io.github.eisop:checker:3.34.0-eisop1' testImplementation 'org.junit.jupiter:junit-jupiter-api:5.9.3' From 763b442abebe072a0377c96c3673fd09ca3ab459 Mon Sep 17 00:00:00 2001 From: Mattias Ulbrich Date: Mon, 26 Jun 2023 13:46:29 +0200 Subject: [PATCH 05/37] making all classes in util nullness aware --- build.gradle | 2 +- .../org/key_project/util/EqualsModProofIrrelevancyUtil.java | 1 + .../org/key_project/util/EqualsModProofIrrelevancyWrapper.java | 1 + key.util/src/main/java/org/key_project/util/ExtList.java | 1 + key.util/src/main/java/org/key_project/util/Filenames.java | 1 + key.util/src/main/java/org/key_project/util/LRUCache.java | 1 + key.util/src/main/java/org/key_project/util/RandomName.java | 1 + key.util/src/main/java/org/key_project/util/Streams.java | 1 + key.util/src/main/java/org/key_project/util/Strings.java | 2 ++ key.util/src/main/java/org/key_project/util/bean/Bean.java | 1 + .../org/key_project/util/bitops/ImmutableFixedLengthBitSet.java | 1 + .../main/java/org/key_project/util/collection/DefaultEdge.java | 1 + .../org/key_project/util/collection/DefaultImmutableMap.java | 1 + .../org/key_project/util/collection/DefaultImmutableSet.java | 1 + .../java/org/key_project/util/collection/DirectedGraph.java | 1 + .../java/org/key_project/util/collection/ImmutableArray.java | 1 + .../org/key_project/util/collection/ImmutableLeftistHeap.java | 1 + .../java/org/key_project/util/collection/ImmutableSLList.java | 2 +- .../main/java/org/key_project/util/collection/ImmutableSet.java | 1 + .../main/java/org/key_project/util/collection/Immutables.java | 1 + .../java/org/key_project/util/collection/KeYCollections.java | 1 + .../org/key_project/util/collection/NotUniqueException.java | 1 + .../java/org/key_project/util/collection/PropertiesUtil.java | 1 + .../main/java/org/key_project/util/helper/FindResources.java | 1 + .../org/key_project/util/helper/HelperClassForUtilityTests.java | 1 + key.util/src/main/java/org/key_project/util/java/ArrayUtil.java | 1 + .../src/main/java/org/key_project/util/java/CollectionUtil.java | 1 + key.util/src/main/java/org/key_project/util/java/IOUtil.java | 1 + .../src/main/java/org/key_project/util/java/IntegerUtil.java | 1 + key.util/src/main/java/org/key_project/util/java/MapUtil.java | 1 + .../src/main/java/org/key_project/util/java/NumberUtil.java | 1 + key.util/src/main/java/org/key_project/util/java/WrapUtils.java | 1 + key.util/src/main/java/org/key_project/util/java/XMLUtil.java | 1 + .../util/java/thread/AbstractRunnableWithException.java | 1 + .../util/java/thread/AbstractRunnableWithResult.java | 1 + .../java/org/key_project/util/lookup/InjectionException.java | 1 + key.util/src/main/java/org/key_project/util/lookup/Lookup.java | 1 + .../java/org/key_project/util/reflection/ClassLoaderUtil.java | 1 + .../key_project/util/reflection/JavaApplicationClassLoader.java | 1 + 39 files changed, 40 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index fa473fe1ce4..bcaf5563441 100644 --- a/build.gradle +++ b/build.gradle @@ -419,7 +419,7 @@ subprojects { "org.checkerframework.checker.nullness.NullnessChecker", ] extraJavacArgs = [ - "-AonlyDefs=^org\\.key_project\\.util\\.lookup", + "-AonlyDefs=^org\\.key_project\\.util", "-Xmaxerrs", "10000", "-Werror", "-Aversion", diff --git a/key.util/src/main/java/org/key_project/util/EqualsModProofIrrelevancyUtil.java b/key.util/src/main/java/org/key_project/util/EqualsModProofIrrelevancyUtil.java index 9e6e1e7d965..6e8dc28668b 100644 --- a/key.util/src/main/java/org/key_project/util/EqualsModProofIrrelevancyUtil.java +++ b/key.util/src/main/java/org/key_project/util/EqualsModProofIrrelevancyUtil.java @@ -10,6 +10,7 @@ * * @author Arne Keller */ +@SuppressWarnings("nullness") public final class EqualsModProofIrrelevancyUtil { private EqualsModProofIrrelevancyUtil() { diff --git a/key.util/src/main/java/org/key_project/util/EqualsModProofIrrelevancyWrapper.java b/key.util/src/main/java/org/key_project/util/EqualsModProofIrrelevancyWrapper.java index c80c3a8fdfa..92f40585468 100644 --- a/key.util/src/main/java/org/key_project/util/EqualsModProofIrrelevancyWrapper.java +++ b/key.util/src/main/java/org/key_project/util/EqualsModProofIrrelevancyWrapper.java @@ -9,6 +9,7 @@ * @param type to wrap * @author Arne Keller */ +@SuppressWarnings("nullness") public class EqualsModProofIrrelevancyWrapper { /** * The wrapped object. diff --git a/key.util/src/main/java/org/key_project/util/ExtList.java b/key.util/src/main/java/org/key_project/util/ExtList.java index 8d5bf780754..460a4770592 100644 --- a/key.util/src/main/java/org/key_project/util/ExtList.java +++ b/key.util/src/main/java/org/key_project/util/ExtList.java @@ -10,6 +10,7 @@ * Extends java.util.LinkedList in order to collect elements according to their type. * Has facilities to get elements of a certain type ({@link #get(Class)}, {@link #collect(Class)}). */ +@SuppressWarnings("nullness") public class ExtList extends LinkedList { private static final long serialVersionUID = 9182017368310263908L; diff --git a/key.util/src/main/java/org/key_project/util/Filenames.java b/key.util/src/main/java/org/key_project/util/Filenames.java index b7122a98e48..05fcbb78483 100644 --- a/key.util/src/main/java/org/key_project/util/Filenames.java +++ b/key.util/src/main/java/org/key_project/util/Filenames.java @@ -9,6 +9,7 @@ * @author Alexander Weigl * @version 1 (29.03.19) */ +@SuppressWarnings("nullness") public class Filenames { // ======================================================= // Methods operating on Strings diff --git a/key.util/src/main/java/org/key_project/util/LRUCache.java b/key.util/src/main/java/org/key_project/util/LRUCache.java index 7690a5975b3..3488b9d6db4 100644 --- a/key.util/src/main/java/org/key_project/util/LRUCache.java +++ b/key.util/src/main/java/org/key_project/util/LRUCache.java @@ -6,6 +6,7 @@ /** * Simple realisation of an LRU cache. */ +@SuppressWarnings("nullness") public class LRUCache extends LinkedHashMap { /** diff --git a/key.util/src/main/java/org/key_project/util/RandomName.java b/key.util/src/main/java/org/key_project/util/RandomName.java index 976e13d7b71..a62cc7c8358 100644 --- a/key.util/src/main/java/org/key_project/util/RandomName.java +++ b/key.util/src/main/java/org/key_project/util/RandomName.java @@ -6,6 +6,7 @@ * @author Alexander Weigl * @version 1 (06.12.18) */ +@SuppressWarnings("nullness") public class RandomName { private static final Random random = new Random(); diff --git a/key.util/src/main/java/org/key_project/util/Streams.java b/key.util/src/main/java/org/key_project/util/Streams.java index 6cc8b817209..b10f298b2b2 100644 --- a/key.util/src/main/java/org/key_project/util/Streams.java +++ b/key.util/src/main/java/org/key_project/util/Streams.java @@ -4,6 +4,7 @@ import java.io.IOException; import java.io.InputStream; +@SuppressWarnings("nullness") public class Streams { private Streams() { diff --git a/key.util/src/main/java/org/key_project/util/Strings.java b/key.util/src/main/java/org/key_project/util/Strings.java index 55e292a1257..1bfa338ea74 100644 --- a/key.util/src/main/java/org/key_project/util/Strings.java +++ b/key.util/src/main/java/org/key_project/util/Strings.java @@ -1,5 +1,6 @@ package org.key_project.util; +import org.jspecify.annotations.NullMarked; import org.key_project.util.java.StringUtil; /** @@ -8,6 +9,7 @@ * @author Alexander Weigl * @version 1 (29.03.19) */ +@NullMarked public class Strings { /** * @deprecated This class has been merged with {@link org.key_project.util.java.StringUtil}. diff --git a/key.util/src/main/java/org/key_project/util/bean/Bean.java b/key.util/src/main/java/org/key_project/util/bean/Bean.java index d9d8a085c16..04c5899a2ca 100644 --- a/key.util/src/main/java/org/key_project/util/bean/Bean.java +++ b/key.util/src/main/java/org/key_project/util/bean/Bean.java @@ -13,6 +13,7 @@ * @author Martin Hentschel * @see IBean */ +@SuppressWarnings("nullness") public class Bean implements IBean { /** * The used {@link PropertyChangeSupport}. diff --git a/key.util/src/main/java/org/key_project/util/bitops/ImmutableFixedLengthBitSet.java b/key.util/src/main/java/org/key_project/util/bitops/ImmutableFixedLengthBitSet.java index b8f6c19ecc8..4e1fafae447 100644 --- a/key.util/src/main/java/org/key_project/util/bitops/ImmutableFixedLengthBitSet.java +++ b/key.util/src/main/java/org/key_project/util/bitops/ImmutableFixedLengthBitSet.java @@ -9,6 +9,7 @@ * * @author Dominic Scheurer */ +@SuppressWarnings("nullness") public class ImmutableFixedLengthBitSet { private boolean[] bitSet = null; diff --git a/key.util/src/main/java/org/key_project/util/collection/DefaultEdge.java b/key.util/src/main/java/org/key_project/util/collection/DefaultEdge.java index a2b422b1ca6..3562fa26b76 100644 --- a/key.util/src/main/java/org/key_project/util/collection/DefaultEdge.java +++ b/key.util/src/main/java/org/key_project/util/collection/DefaultEdge.java @@ -6,6 +6,7 @@ * * @author Arne Keller */ +@SuppressWarnings("nullness") public class DefaultEdge implements GraphEdge { /** * Source node of this edge. diff --git a/key.util/src/main/java/org/key_project/util/collection/DefaultImmutableMap.java b/key.util/src/main/java/org/key_project/util/collection/DefaultImmutableMap.java index c903a8a3c90..b81a4d7327d 100644 --- a/key.util/src/main/java/org/key_project/util/collection/DefaultImmutableMap.java +++ b/key.util/src/main/java/org/key_project/util/collection/DefaultImmutableMap.java @@ -6,6 +6,7 @@ * This class implements ImmMap and provides a persistent Map. It is a simple implementation * like lists */ +@SuppressWarnings("nullness") public class DefaultImmutableMap implements ImmutableMap { /** diff --git a/key.util/src/main/java/org/key_project/util/collection/DefaultImmutableSet.java b/key.util/src/main/java/org/key_project/util/collection/DefaultImmutableSet.java index 37b5d60c728..486f3988989 100644 --- a/key.util/src/main/java/org/key_project/util/collection/DefaultImmutableSet.java +++ b/key.util/src/main/java/org/key_project/util/collection/DefaultImmutableSet.java @@ -15,6 +15,7 @@ * * @param type of object to store */ +@SuppressWarnings("nullness") public class DefaultImmutableSet implements ImmutableSet { /** diff --git a/key.util/src/main/java/org/key_project/util/collection/DirectedGraph.java b/key.util/src/main/java/org/key_project/util/collection/DirectedGraph.java index dfc67953ff1..1bd08b623c5 100644 --- a/key.util/src/main/java/org/key_project/util/collection/DirectedGraph.java +++ b/key.util/src/main/java/org/key_project/util/collection/DirectedGraph.java @@ -14,6 +14,7 @@ * @param edge type * @author Arne Keller */ +@SuppressWarnings("nullness") public class DirectedGraph implements Graph { /** * Set of vertices in this graph. diff --git a/key.util/src/main/java/org/key_project/util/collection/ImmutableArray.java b/key.util/src/main/java/org/key_project/util/collection/ImmutableArray.java index 3723550909d..29619b553cd 100644 --- a/key.util/src/main/java/org/key_project/util/collection/ImmutableArray.java +++ b/key.util/src/main/java/org/key_project/util/collection/ImmutableArray.java @@ -10,6 +10,7 @@ import java.util.stream.StreamSupport; import javax.annotation.Nonnull; +@SuppressWarnings("nullness") public class ImmutableArray implements java.lang.Iterable, java.io.Serializable { /** diff --git a/key.util/src/main/java/org/key_project/util/collection/ImmutableLeftistHeap.java b/key.util/src/main/java/org/key_project/util/collection/ImmutableLeftistHeap.java index 7fd38d909f2..baa197a1f45 100644 --- a/key.util/src/main/java/org/key_project/util/collection/ImmutableLeftistHeap.java +++ b/key.util/src/main/java/org/key_project/util/collection/ImmutableLeftistHeap.java @@ -7,6 +7,7 @@ * This class implements the leftist heap, see "Functional Data Structures" by Chris * Okasaki */ +@SuppressWarnings("nullness") public abstract class ImmutableLeftistHeap> implements ImmutableHeap { /** diff --git a/key.util/src/main/java/org/key_project/util/collection/ImmutableSLList.java b/key.util/src/main/java/org/key_project/util/collection/ImmutableSLList.java index 2ac3f8c1fd7..c189524f6fd 100644 --- a/key.util/src/main/java/org/key_project/util/collection/ImmutableSLList.java +++ b/key.util/src/main/java/org/key_project/util/collection/ImmutableSLList.java @@ -20,7 +20,7 @@ * and head with amortized O(1). This will be done later (if necessary). */ -@SuppressWarnings("unchecked") +@SuppressWarnings({"unchecked", "nullness"}) public abstract class ImmutableSLList implements ImmutableList { /** diff --git a/key.util/src/main/java/org/key_project/util/collection/ImmutableSet.java b/key.util/src/main/java/org/key_project/util/collection/ImmutableSet.java index b1c1655c51a..6264ae12d9d 100644 --- a/key.util/src/main/java/org/key_project/util/collection/ImmutableSet.java +++ b/key.util/src/main/java/org/key_project/util/collection/ImmutableSet.java @@ -12,6 +12,7 @@ * offer a public static final variable .nil() */ +@SuppressWarnings("nullness") public interface ImmutableSet extends Iterable, java.io.Serializable { /** diff --git a/key.util/src/main/java/org/key_project/util/collection/Immutables.java b/key.util/src/main/java/org/key_project/util/collection/Immutables.java index 7401b27e682..b37b1c36729 100644 --- a/key.util/src/main/java/org/key_project/util/collection/Immutables.java +++ b/key.util/src/main/java/org/key_project/util/collection/Immutables.java @@ -13,6 +13,7 @@ * * @author Mattias Ulbrich */ +@SuppressWarnings("nullness") public final class Immutables { private Immutables() { diff --git a/key.util/src/main/java/org/key_project/util/collection/KeYCollections.java b/key.util/src/main/java/org/key_project/util/collection/KeYCollections.java index 00acea0741a..11d479a6f91 100644 --- a/key.util/src/main/java/org/key_project/util/collection/KeYCollections.java +++ b/key.util/src/main/java/org/key_project/util/collection/KeYCollections.java @@ -14,6 +14,7 @@ * @author Alexander Weigl * @version 1 (29.03.19) */ +@SuppressWarnings("nullness") public class KeYCollections { // ======================================================= // Methods operating on Arrays diff --git a/key.util/src/main/java/org/key_project/util/collection/NotUniqueException.java b/key.util/src/main/java/org/key_project/util/collection/NotUniqueException.java index 340a04eda06..360179ba951 100644 --- a/key.util/src/main/java/org/key_project/util/collection/NotUniqueException.java +++ b/key.util/src/main/java/org/key_project/util/collection/NotUniqueException.java @@ -3,6 +3,7 @@ /** thrown if a duplicate is being added via addUnique() */ +@SuppressWarnings("nullness") public class NotUniqueException extends Exception { private static final long serialVersionUID = 6565515240836947955L; diff --git a/key.util/src/main/java/org/key_project/util/collection/PropertiesUtil.java b/key.util/src/main/java/org/key_project/util/collection/PropertiesUtil.java index b193a693911..d2884d43f9f 100644 --- a/key.util/src/main/java/org/key_project/util/collection/PropertiesUtil.java +++ b/key.util/src/main/java/org/key_project/util/collection/PropertiesUtil.java @@ -7,6 +7,7 @@ import java.nio.charset.StandardCharsets; import java.util.Properties; +@SuppressWarnings("nullness") public class PropertiesUtil { private PropertiesUtil() { diff --git a/key.util/src/main/java/org/key_project/util/helper/FindResources.java b/key.util/src/main/java/org/key_project/util/helper/FindResources.java index 0ee3215b281..a2365f38712 100644 --- a/key.util/src/main/java/org/key_project/util/helper/FindResources.java +++ b/key.util/src/main/java/org/key_project/util/helper/FindResources.java @@ -14,6 +14,7 @@ * @author Alexander Weigl * @version 1 (13.02.19) */ +@SuppressWarnings("nullness") public final class FindResources { /** * List directory contents for a resource folder. Not recursive. This is basically a brute-force diff --git a/key.util/src/main/java/org/key_project/util/helper/HelperClassForUtilityTests.java b/key.util/src/main/java/org/key_project/util/helper/HelperClassForUtilityTests.java index bf55ef35fcb..d4a855147fc 100644 --- a/key.util/src/main/java/org/key_project/util/helper/HelperClassForUtilityTests.java +++ b/key.util/src/main/java/org/key_project/util/helper/HelperClassForUtilityTests.java @@ -5,6 +5,7 @@ import java.io.IOException; import java.nio.charset.StandardCharsets; +@SuppressWarnings("nullness") public class HelperClassForUtilityTests { public static final File RESOURCE_DIRECTORY = FindResources.getTestResourcesDirectory(); diff --git a/key.util/src/main/java/org/key_project/util/java/ArrayUtil.java b/key.util/src/main/java/org/key_project/util/java/ArrayUtil.java index e19552eb30b..03e635d16df 100644 --- a/key.util/src/main/java/org/key_project/util/java/ArrayUtil.java +++ b/key.util/src/main/java/org/key_project/util/java/ArrayUtil.java @@ -10,6 +10,7 @@ * * @author Martin Hentschel */ +@SuppressWarnings("nullness") public final class ArrayUtil { /** * Forbid instances by this private constructor. diff --git a/key.util/src/main/java/org/key_project/util/java/CollectionUtil.java b/key.util/src/main/java/org/key_project/util/java/CollectionUtil.java index 3ce65775909..82a97084db8 100644 --- a/key.util/src/main/java/org/key_project/util/java/CollectionUtil.java +++ b/key.util/src/main/java/org/key_project/util/java/CollectionUtil.java @@ -8,6 +8,7 @@ * * @author Martin Hentschel */ +@SuppressWarnings("nullness") public class CollectionUtil { /** * The default separator. diff --git a/key.util/src/main/java/org/key_project/util/java/IOUtil.java b/key.util/src/main/java/org/key_project/util/java/IOUtil.java index 91a1e6a6c97..37b60c4fa67 100644 --- a/key.util/src/main/java/org/key_project/util/java/IOUtil.java +++ b/key.util/src/main/java/org/key_project/util/java/IOUtil.java @@ -18,6 +18,7 @@ * * @author Martin Hentschel */ +@SuppressWarnings("nullness") public final class IOUtil { /** * The size of used buffers. diff --git a/key.util/src/main/java/org/key_project/util/java/IntegerUtil.java b/key.util/src/main/java/org/key_project/util/java/IntegerUtil.java index 495fd5ae775..1dd354bf163 100644 --- a/key.util/src/main/java/org/key_project/util/java/IntegerUtil.java +++ b/key.util/src/main/java/org/key_project/util/java/IntegerUtil.java @@ -1,5 +1,6 @@ package org.key_project.util.java; +@SuppressWarnings("nullness") public final class IntegerUtil { /** * Forbid instances. diff --git a/key.util/src/main/java/org/key_project/util/java/MapUtil.java b/key.util/src/main/java/org/key_project/util/java/MapUtil.java index d6d441fb87a..37712c59b15 100644 --- a/key.util/src/main/java/org/key_project/util/java/MapUtil.java +++ b/key.util/src/main/java/org/key_project/util/java/MapUtil.java @@ -12,6 +12,7 @@ * * @author lanzinger */ +@SuppressWarnings("nullness") public final class MapUtil { private MapUtil() {} diff --git a/key.util/src/main/java/org/key_project/util/java/NumberUtil.java b/key.util/src/main/java/org/key_project/util/java/NumberUtil.java index 2c77796e405..76c34dac6f5 100644 --- a/key.util/src/main/java/org/key_project/util/java/NumberUtil.java +++ b/key.util/src/main/java/org/key_project/util/java/NumberUtil.java @@ -5,6 +5,7 @@ * * @author Martin Hentschel */ +@SuppressWarnings("nullness") public class NumberUtil { /** * The maximal number of digits of an integer value. diff --git a/key.util/src/main/java/org/key_project/util/java/WrapUtils.java b/key.util/src/main/java/org/key_project/util/java/WrapUtils.java index 2c6cdfc4657..09f264ef2f0 100644 --- a/key.util/src/main/java/org/key_project/util/java/WrapUtils.java +++ b/key.util/src/main/java/org/key_project/util/java/WrapUtils.java @@ -13,6 +13,7 @@ * * @author Mattias Ulbrich, Mar 2021 */ +@SuppressWarnings("nullness") public class WrapUtils { /* diff --git a/key.util/src/main/java/org/key_project/util/java/XMLUtil.java b/key.util/src/main/java/org/key_project/util/java/XMLUtil.java index 508ad47f6ad..f57110156c7 100644 --- a/key.util/src/main/java/org/key_project/util/java/XMLUtil.java +++ b/key.util/src/main/java/org/key_project/util/java/XMLUtil.java @@ -8,6 +8,7 @@ * * @author Martin Hentschel */ +@SuppressWarnings("nullness") public final class XMLUtil { /** * Attribute name to store encodings. diff --git a/key.util/src/main/java/org/key_project/util/java/thread/AbstractRunnableWithException.java b/key.util/src/main/java/org/key_project/util/java/thread/AbstractRunnableWithException.java index c9d889e5e71..adb9aa9ca68 100644 --- a/key.util/src/main/java/org/key_project/util/java/thread/AbstractRunnableWithException.java +++ b/key.util/src/main/java/org/key_project/util/java/thread/AbstractRunnableWithException.java @@ -12,6 +12,7 @@ * @author Martin Hentschel * @see IRunnableWithResult */ +@SuppressWarnings("nullness") public abstract class AbstractRunnableWithException implements IRunnableWithException { /** * An occurred exception. diff --git a/key.util/src/main/java/org/key_project/util/java/thread/AbstractRunnableWithResult.java b/key.util/src/main/java/org/key_project/util/java/thread/AbstractRunnableWithResult.java index 91ddb7aad27..a05c67b1696 100644 --- a/key.util/src/main/java/org/key_project/util/java/thread/AbstractRunnableWithResult.java +++ b/key.util/src/main/java/org/key_project/util/java/thread/AbstractRunnableWithResult.java @@ -12,6 +12,7 @@ * @author Martin Hentschel * @see IRunnableWithResult */ +@SuppressWarnings("nullness") public abstract class AbstractRunnableWithResult extends AbstractRunnableWithException implements IRunnableWithResult { /** diff --git a/key.util/src/main/java/org/key_project/util/lookup/InjectionException.java b/key.util/src/main/java/org/key_project/util/lookup/InjectionException.java index 863f301d044..2b61eb564c2 100644 --- a/key.util/src/main/java/org/key_project/util/lookup/InjectionException.java +++ b/key.util/src/main/java/org/key_project/util/lookup/InjectionException.java @@ -4,6 +4,7 @@ * @author Alexander Weigl * @version 1 (13.01.19) */ +@SuppressWarnings("nullness") public class InjectionException extends RuntimeException { private static final long serialVersionUID = 119998955722036861L; diff --git a/key.util/src/main/java/org/key_project/util/lookup/Lookup.java b/key.util/src/main/java/org/key_project/util/lookup/Lookup.java index 441e91b69fa..254a6e3cd81 100644 --- a/key.util/src/main/java/org/key_project/util/lookup/Lookup.java +++ b/key.util/src/main/java/org/key_project/util/lookup/Lookup.java @@ -24,6 +24,7 @@ * @version 1 (15.03.19) */ @NullMarked +@SuppressWarnings("nullness") public class Lookup { public static final Lookup DEFAULT = new Lookup(); diff --git a/key.util/src/main/java/org/key_project/util/reflection/ClassLoaderUtil.java b/key.util/src/main/java/org/key_project/util/reflection/ClassLoaderUtil.java index 1601f192add..b58cab00727 100644 --- a/key.util/src/main/java/org/key_project/util/reflection/ClassLoaderUtil.java +++ b/key.util/src/main/java/org/key_project/util/reflection/ClassLoaderUtil.java @@ -35,6 +35,7 @@ * @see IClassLoader * @see JavaApplicationClassLoader */ +@SuppressWarnings("nullness") public class ClassLoaderUtil { /** * The {@link IClassLoader} instance to use. diff --git a/key.util/src/main/java/org/key_project/util/reflection/JavaApplicationClassLoader.java b/key.util/src/main/java/org/key_project/util/reflection/JavaApplicationClassLoader.java index b7f07142c5e..38feed62992 100644 --- a/key.util/src/main/java/org/key_project/util/reflection/JavaApplicationClassLoader.java +++ b/key.util/src/main/java/org/key_project/util/reflection/JavaApplicationClassLoader.java @@ -10,6 +10,7 @@ * * @author Martin Hentschel */ +@SuppressWarnings("nullness") public class JavaApplicationClassLoader implements IClassLoader { /** * {@inheritDoc} From 08673f9350e602d911567a18fa302e1e3911a4e2 Mon Sep 17 00:00:00 2001 From: Mattias Ulbrich Date: Mon, 26 Jun 2023 13:46:45 +0200 Subject: [PATCH 06/37] nullness-specifying the StringUtil class --- .../java/org/key_project/util/Strings.java | 3 +- .../util/collection/ImmutableSLList.java | 2 +- .../org/key_project/util/java/StringUtil.java | 60 +++++++++++-------- 3 files changed, 38 insertions(+), 27 deletions(-) diff --git a/key.util/src/main/java/org/key_project/util/Strings.java b/key.util/src/main/java/org/key_project/util/Strings.java index 1bfa338ea74..cd071b422ef 100644 --- a/key.util/src/main/java/org/key_project/util/Strings.java +++ b/key.util/src/main/java/org/key_project/util/Strings.java @@ -1,8 +1,9 @@ package org.key_project.util; -import org.jspecify.annotations.NullMarked; import org.key_project.util.java.StringUtil; +import org.jspecify.annotations.NullMarked; + /** * Helper functions for {@link String}s * diff --git a/key.util/src/main/java/org/key_project/util/collection/ImmutableSLList.java b/key.util/src/main/java/org/key_project/util/collection/ImmutableSLList.java index c189524f6fd..e1bab0f04f2 100644 --- a/key.util/src/main/java/org/key_project/util/collection/ImmutableSLList.java +++ b/key.util/src/main/java/org/key_project/util/collection/ImmutableSLList.java @@ -20,7 +20,7 @@ * and head with amortized O(1). This will be done later (if necessary). */ -@SuppressWarnings({"unchecked", "nullness"}) +@SuppressWarnings({ "unchecked", "nullness" }) public abstract class ImmutableSLList implements ImmutableList { /** diff --git a/key.util/src/main/java/org/key_project/util/java/StringUtil.java b/key.util/src/main/java/org/key_project/util/java/StringUtil.java index 976dca45680..cd231587cbc 100644 --- a/key.util/src/main/java/org/key_project/util/java/StringUtil.java +++ b/key.util/src/main/java/org/key_project/util/java/StringUtil.java @@ -5,15 +5,20 @@ import java.util.function.Predicate; import java.util.regex.Matcher; import java.util.regex.Pattern; -import javax.annotation.Nonnull; import javax.swing.*; +import org.checkerframework.checker.nullness.qual.AssertNonNullIfNonNull; +import org.jspecify.annotations.NonNull; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; + /** * Provides static methods to work with strings. * * @author Martin Hentschel */ +@NullMarked public final class StringUtil { /** Pattern for newlines */ private static final Pattern NEWLINE_PATTERN = Pattern.compile("(\\r\\n|\\r|\\n)"); @@ -74,7 +79,7 @@ private StringUtil() { * @param text The text to check. * @return {@code true} = text is {@code null} or empty, {@code false} = text is not empty. */ - public static boolean isEmpty(String text) { + public static boolean isEmpty(@Nullable String text) { return text == null || text.isEmpty(); } @@ -85,7 +90,7 @@ public static boolean isEmpty(String text) { * @return {@code true} = text is {@code null} or trimmed empty, {@code false} = text is not * empty. */ - public static boolean isTrimmedEmpty(String text) { + public static boolean isTrimmedEmpty(@Nullable String text) { return text == null || text.trim().isEmpty(); } @@ -95,7 +100,7 @@ public static boolean isTrimmedEmpty(String text) { * @param text The text. * @return The trimmed text. */ - public static String trim(String text) { + public static @Nullable String trim(@Nullable String text) { return text != null ? text.trim() : null; } @@ -105,7 +110,8 @@ public static String trim(String text) { * @param text The text to convert. * @return The text in lower case or {@code null} if the given text is {@code null}. */ - public static String toLowerCase(String text) { + public static @AssertNonNullIfNonNull("text") @Nullable String toLowerCase( + @Nullable String text) { return text != null ? text.toLowerCase() : null; } @@ -153,7 +159,7 @@ public static String repeat(String text, int repetitions) { * {@code false} if at least one string is {@code null} or the string does not contain * the substring. */ - public static boolean contains(String string, CharSequence substring) { + public static boolean contains(@Nullable String string, @Nullable CharSequence substring) { return string != null && substring != null && string.contains(substring); } @@ -168,7 +174,7 @@ public static boolean contains(String string, CharSequence substring) { * * @author Mattias Ulbrich (under GPL) */ - public static String wrapLines(String string, int length) { + public static @NonNull String wrapLines(@NonNull String string, int length) { char[] c = string.toCharArray(); WrapUtils.wrapLines(c, length); return new String(c); @@ -184,7 +190,7 @@ public static String wrapLines(String string, int length) { * * @author Mattias Ulbrich (under GPL) */ - public static String wrapLines(String string) { + public static @NonNull String wrapLines(@NonNull String string) { return wrapLines(string, 100); } @@ -195,7 +201,7 @@ public static String wrapLines(String string) { * @param text The text to convert. * @return The single lined text. */ - public static String toSingleLinedString(String text) { + public static @Nullable String toSingleLinedString(@Nullable String text) { return replaceAll(text, new char[] { '\n', '\r', '\t' }, ' '); } @@ -207,7 +213,8 @@ public static String toSingleLinedString(String text) { * @param toReplace The sign to replace with. * @return The new created {@link String}. */ - public static String replaceAll(String text, char[] toSearch, char toReplace) { + public static @Nullable String replaceAll(@Nullable String text, char[] toSearch, + char toReplace) { if (text != null && toSearch != null) { // Sort toSearch Arrays.sort(toSearch); @@ -232,7 +239,7 @@ public static String replaceAll(String text, char[] toSearch, char toReplace) { * @param second The second {@link String}. * @return {@code true} equal ignoring whitespace, {@code false} different. */ - public static boolean equalIgnoreWhiteSpace(String first, String second) { + public static boolean equalIgnoreWhiteSpace(@Nullable String first, @Nullable String second) { if (first != null) { if (second != null) { char[] firstContent = first.toCharArray(); @@ -295,7 +302,8 @@ && contains(WHITESPACE, secondContent[secondIndex] + EMPTY_STRING)) { * @return The created text. * @throws IllegalArgumentException If the text is already longer as the given length */ - public static String fillString(String text, char leadingCharacter, int length) + public static @NonNull String fillString(@Nullable String text, char leadingCharacter, + int length) throws IllegalArgumentException { StringBuilder sb = new StringBuilder(); if (text != null) { @@ -322,7 +330,8 @@ public static String fillString(String text, char leadingCharacter, int length) * @param text The text to trim its right side. * @return The trimmed text. */ - public static String trimRight(String text) { + public static @AssertNonNullIfNonNull("text") @Nullable String trimRight( + @Nullable String text) { if (text != null) { char[] content = text.toCharArray(); int newLength = content.length; @@ -342,7 +351,8 @@ public static String trimRight(String text) { * @param maxLength The maximal length to ensure. * @return The text considering the maximal length. */ - public static String chop(String text, int maxLength) { + public static @AssertNonNullIfNonNull("text") @Nullable String chop(@Nullable String text, + int maxLength) { if (text != null && text.length() > maxLength) { if (maxLength <= 0) { return EMPTY_STRING; @@ -368,11 +378,11 @@ public static String chop(String text, int maxLength) { * @return {@code true} {@link Object} is {@link String} with given prefix, {@code false} * otherwise. */ - public static boolean startsWith(Object obj, String prefix) { + public static boolean startsWith(@Nullable Object obj, @Nullable String prefix) { return obj instanceof String && prefix != null && ((String) obj).startsWith(prefix); } - public static boolean isNumber(String val) { + public static boolean isNumber(@NonNull String val) { try { Long.parseLong(val); } catch (NumberFormatException e) { @@ -389,8 +399,8 @@ public static boolean isNumber(String val) { * * The given predicate test the characters, if true the character is removed. */ - @Nonnull - public static String trim(@Nonnull String text, @Nonnull Predicate predicate) { + public static @NonNull String trim(@NonNull String text, + @NonNull Predicate predicate) { int first = 0; int last = text.length() - 1; char[] value = text.toCharArray(); @@ -409,8 +419,8 @@ public static String trim(@Nonnull String text, @Nonnull Predicate pr * * @see #trim(String, Predicate) */ - @Nonnull - public static String trim(String text, char c) { + + public static @NonNull String trim(@NonNull String text, char c) { return trim(text, it -> it == c); } @@ -419,8 +429,8 @@ public static String trim(String text, char c) { * * @see #trim(String, Predicate) */ - @Nonnull - public static String trim(String text, String chars) { + + public static @NonNull String trim(@NonNull String text, @NonNull String chars) { return trim(text, it -> chars.indexOf(it) >= 0); } @@ -431,7 +441,7 @@ public static String trim(String text, String chars) { * @param with with * @return the normalized text. */ - public static String replaceNewlines(String text, String with) { + public static @NonNull String replaceNewlines(@NonNull String text, String with) { return NEWLINE_PATTERN.matcher(text).replaceAll(with); } @@ -442,7 +452,7 @@ public static String replaceNewlines(String text, String with) { * @param s string to search in * @param word string to be searched for */ - public static boolean containsWholeWord(String s, String word) { + public static boolean containsWholeWord(@NonNull String s, @NonNull String word) { Pattern p = Pattern.compile("\\b" + word + "\\b"); Matcher m = p.matcher(s); return m.find(); @@ -462,7 +472,7 @@ public static boolean containsWholeWord(String s, String word) { * @param comment * @return */ - public static boolean isJMLComment(String comment) { + public static boolean isJMLComment(@NonNull String comment) { try { return (comment.startsWith("/*@") || comment.startsWith("//@") || comment.startsWith("/*+KeY@") || comment.startsWith("//+KeY@") From de7cdae3c794c81c5914253ff957d9783f677cb1 Mon Sep 17 00:00:00 2001 From: Mattias Ulbrich Date: Mon, 26 Jun 2023 13:56:03 +0200 Subject: [PATCH 07/37] nullness-specifying class Filenames --- .../src/main/java/org/key_project/util/Filenames.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/key.util/src/main/java/org/key_project/util/Filenames.java b/key.util/src/main/java/org/key_project/util/Filenames.java index 05fcbb78483..6046c3f239b 100644 --- a/key.util/src/main/java/org/key_project/util/Filenames.java +++ b/key.util/src/main/java/org/key_project/util/Filenames.java @@ -5,11 +5,13 @@ import java.util.Arrays; import java.util.List; +import org.jspecify.annotations.NullMarked; + /** * @author Alexander Weigl * @version 1 (29.03.19) */ -@SuppressWarnings("nullness") +@NullMarked public class Filenames { // ======================================================= // Methods operating on Strings @@ -154,7 +156,9 @@ private static String[] removeDotDot(String[] a) { if (!a[a.length - 1].equals("..")) { newa[k++] = a[a.length - 1]; } - return Arrays.copyOf(newa, k); + // @ assert (\forall int i; 0 <= i < k; newa[i] != null); + // TODO: nullness. This cast cannot be checked, can it? But there is no error message + return (String[]) Arrays.copyOf(newa, k); } public static String toValidFileName(String s) { From 652efd5e06502e563a7d72db7fefcfa620ffbf2f Mon Sep 17 00:00:00 2001 From: Mattias Ulbrich Date: Mon, 26 Jun 2023 22:09:38 +0200 Subject: [PATCH 08/37] nonnull: addressing Werner's review comments --- .../java/org/key_project/util/java/StringUtil.java | 11 ++++------- .../main/java/org/key_project/util/lookup/Lookup.java | 1 - 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/key.util/src/main/java/org/key_project/util/java/StringUtil.java b/key.util/src/main/java/org/key_project/util/java/StringUtil.java index cd231587cbc..4a90df908ae 100644 --- a/key.util/src/main/java/org/key_project/util/java/StringUtil.java +++ b/key.util/src/main/java/org/key_project/util/java/StringUtil.java @@ -7,7 +7,7 @@ import java.util.regex.Pattern; import javax.swing.*; -import org.checkerframework.checker.nullness.qual.AssertNonNullIfNonNull; +import org.checkerframework.checker.nullness.qual.PolyNull; import org.jspecify.annotations.NonNull; import org.jspecify.annotations.NullMarked; import org.jspecify.annotations.Nullable; @@ -110,8 +110,7 @@ public static boolean isTrimmedEmpty(@Nullable String text) { * @param text The text to convert. * @return The text in lower case or {@code null} if the given text is {@code null}. */ - public static @AssertNonNullIfNonNull("text") @Nullable String toLowerCase( - @Nullable String text) { + public static @PolyNull String toLowerCase(@PolyNull String text) { return text != null ? text.toLowerCase() : null; } @@ -330,8 +329,7 @@ && contains(WHITESPACE, secondContent[secondIndex] + EMPTY_STRING)) { * @param text The text to trim its right side. * @return The trimmed text. */ - public static @AssertNonNullIfNonNull("text") @Nullable String trimRight( - @Nullable String text) { + public static @PolyNull String trimRight(@PolyNull String text) { if (text != null) { char[] content = text.toCharArray(); int newLength = content.length; @@ -351,8 +349,7 @@ && contains(WHITESPACE, secondContent[secondIndex] + EMPTY_STRING)) { * @param maxLength The maximal length to ensure. * @return The text considering the maximal length. */ - public static @AssertNonNullIfNonNull("text") @Nullable String chop(@Nullable String text, - int maxLength) { + public static @PolyNull String chop(@PolyNull String text, int maxLength) { if (text != null && text.length() > maxLength) { if (maxLength <= 0) { return EMPTY_STRING; diff --git a/key.util/src/main/java/org/key_project/util/lookup/Lookup.java b/key.util/src/main/java/org/key_project/util/lookup/Lookup.java index 254a6e3cd81..441e91b69fa 100644 --- a/key.util/src/main/java/org/key_project/util/lookup/Lookup.java +++ b/key.util/src/main/java/org/key_project/util/lookup/Lookup.java @@ -24,7 +24,6 @@ * @version 1 (15.03.19) */ @NullMarked -@SuppressWarnings("nullness") public class Lookup { public static final Lookup DEFAULT = new Lookup(); From f95c90b3ecc6afd2afd2df9cf1b9127537a11592 Mon Sep 17 00:00:00 2001 From: Mattias Ulbrich Date: Mon, 26 Jun 2023 23:07:32 +0200 Subject: [PATCH 09/37] nullness-specifying some more classes (not all checks are successful and need some more discussion!) --- .../java/org/key_project/util/ExtList.java | 12 +++-- .../java/org/key_project/util/RandomName.java | 5 +- .../bitops/ImmutableFixedLengthBitSet.java | 9 ++-- .../org/key_project/util/java/IOUtil.java | 48 +++++++++++-------- .../org/key_project/util/java/NumberUtil.java | 4 +- .../org/key_project/util/java/StringUtil.java | 2 +- .../org/key_project/util/java/WrapUtils.java | 3 +- .../org/key_project/util/java/XMLUtil.java | 17 ++++--- 8 files changed, 62 insertions(+), 38 deletions(-) diff --git a/key.util/src/main/java/org/key_project/util/ExtList.java b/key.util/src/main/java/org/key_project/util/ExtList.java index 460a4770592..5ef551fd969 100644 --- a/key.util/src/main/java/org/key_project/util/ExtList.java +++ b/key.util/src/main/java/org/key_project/util/ExtList.java @@ -1,16 +1,20 @@ package org.key_project.util; +import org.jspecify.annotations.NonNull; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; + import java.util.Arrays; import java.util.Iterator; import java.util.LinkedList; - +import java.util.List; /** * Extends java.util.LinkedList in order to collect elements according to their type. * Has facilities to get elements of a certain type ({@link #get(Class)}, {@link #collect(Class)}). */ -@SuppressWarnings("nullness") +@NullMarked public class ExtList extends LinkedList { private static final long serialVersionUID = 9182017368310263908L; @@ -58,7 +62,7 @@ public T[] collect(Class cl) { * @return the first element with type cl in list */ @SuppressWarnings("unchecked") - public T get(Class cl) { + public @Nullable T get(Class cl) { for (Object next : this) { if (cl.isInstance(next) && (next != null)) { return (T) next; @@ -76,7 +80,7 @@ public T get(Class cl) { * @return the first element with type cl in list */ @SuppressWarnings("unchecked") - public T removeFirstOccurrence(Class cl) { + public @Nullable T removeFirstOccurrence(Class cl) { Iterator it = iterator(); while (it.hasNext()) { Object next = it.next(); diff --git a/key.util/src/main/java/org/key_project/util/RandomName.java b/key.util/src/main/java/org/key_project/util/RandomName.java index a62cc7c8358..06788533359 100644 --- a/key.util/src/main/java/org/key_project/util/RandomName.java +++ b/key.util/src/main/java/org/key_project/util/RandomName.java @@ -1,12 +1,15 @@ package org.key_project.util; +import org.jspecify.annotations.NullMarked; + import java.util.Random; /** * @author Alexander Weigl * @version 1 (06.12.18) */ -@SuppressWarnings("nullness") + +@NullMarked public class RandomName { private static final Random random = new Random(); diff --git a/key.util/src/main/java/org/key_project/util/bitops/ImmutableFixedLengthBitSet.java b/key.util/src/main/java/org/key_project/util/bitops/ImmutableFixedLengthBitSet.java index 4e1fafae447..8998b140ce1 100644 --- a/key.util/src/main/java/org/key_project/util/bitops/ImmutableFixedLengthBitSet.java +++ b/key.util/src/main/java/org/key_project/util/bitops/ImmutableFixedLengthBitSet.java @@ -1,5 +1,8 @@ package org.key_project.util.bitops; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; + import java.util.ArrayList; import java.util.BitSet; @@ -9,11 +12,11 @@ * * @author Dominic Scheurer */ -@SuppressWarnings("nullness") +@NullMarked public class ImmutableFixedLengthBitSet { - private boolean[] bitSet = null; - private int value = -1; + private final boolean[] bitSet; + private int value; /** * Constructs a new {@link ImmutableFixedLengthBitSet} for the given length. All bits are set to diff --git a/key.util/src/main/java/org/key_project/util/java/IOUtil.java b/key.util/src/main/java/org/key_project/util/java/IOUtil.java index 37b60c4fa67..fe320f56351 100644 --- a/key.util/src/main/java/org/key_project/util/java/IOUtil.java +++ b/key.util/src/main/java/org/key_project/util/java/IOUtil.java @@ -1,5 +1,9 @@ package org.key_project.util.java; +import org.checkerframework.checker.nullness.qual.PolyNull; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; + import java.io.*; import java.net.*; import java.nio.charset.Charset; @@ -18,7 +22,7 @@ * * @author Martin Hentschel */ -@SuppressWarnings("nullness") +@NullMarked public final class IOUtil { /** * The size of used buffers. @@ -41,7 +45,7 @@ private IOUtil() { * * @return The home directory. */ - public static File getHomeDirectory() { + public static @Nullable File getHomeDirectory() { String path = System.getProperty("user.home"); if (path != null) { return new File(path); @@ -56,7 +60,7 @@ public static File getHomeDirectory() { * @param file The file to extract it extension. * @return The file extension or {@code null} if not available. */ - public static String getFileExtension(File file) { + public static @Nullable String getFileExtension(@Nullable File file) { if (file != null) { String name = file.getName(); int dotIndex = name.lastIndexOf('.'); @@ -77,7 +81,7 @@ public static String getFileExtension(File file) { * needed. * @return The file name without extension or {@code null} if it was not possible to compute it. */ - public static String getFileNameWithoutExtension(String fileName) { + public static @PolyNull String getFileNameWithoutExtension(@PolyNull String fileName) { if (fileName != null) { int dotIndex = fileName.lastIndexOf('.'); if (dotIndex >= 0) { @@ -147,7 +151,7 @@ public static Optional readFrom(URI url) throws IOException { * existing file. * @throws IOException Occurred Exception. */ - public static String readFrom(File file) throws IOException { + public static @Nullable String readFrom(@Nullable File file) throws IOException { if (file != null && file.isFile()) { return readFrom(new FileInputStream(file)); } else { @@ -162,7 +166,7 @@ public static String readFrom(File file) throws IOException { * @return The read content or {@code null} if the {@link InputStream} is {@code null}. * @throws IOException Occurred Exception. */ - public static String readFrom(InputStream in) throws IOException { + public static @PolyNull String readFrom(@PolyNull InputStream in) throws IOException { if (in == null) { return null; } @@ -212,7 +216,7 @@ public static void writeTo(OutputStream out, String content, Charset encoding) * @param encoding The encoding to use. * @throws IOException Occurred Exception. */ - public static void writeTo(OutputStream out, String content, String encoding) + public static void writeTo(@Nullable OutputStream out, @Nullable String content, @Nullable String encoding) throws IOException { if (out == null || content == null) { return; @@ -297,7 +301,7 @@ public static LineInformation[] computeLineInformation(File file) throws IOExcep * @return The computed start indices. * @throws IOException Occurred Exception. */ - public static LineInformation[] computeLineInformation(InputStream in) throws IOException { + public static LineInformation[] computeLineInformation(@Nullable InputStream in) throws IOException { if (in == null) { return new LineInformation[0]; } @@ -590,7 +594,7 @@ public interface IFileVisitor { * @return A new {@link InputStream} with with the replaced line breaks. * @throws IOException Occurred Exception. */ - public static InputStream unifyLineBreaks(InputStream in) throws IOException { + public static @PolyNull InputStream unifyLineBreaks(@PolyNull InputStream in) throws IOException { if (in != null) { String text = IOUtil.readFrom(in); text = text.replace("\r\n", "\n"); @@ -628,7 +632,7 @@ public static boolean contains(Iterable parents, File child) { * @return {@code true} child is contained (recursive) in parent, {@code false} child is not * contained in parent. */ - public static boolean contains(File parent, File child) { + public static boolean contains(@Nullable File parent, @Nullable File child) { boolean contains = false; if (parent != null && child != null) { while (!contains && child != null) { @@ -713,35 +717,35 @@ public static boolean exists(File file) { return file != null && file.exists(); } - public static URL getClassLocationURL(Class classInstance) { + public static @Nullable URL getClassLocationURL(Class classInstance) { CodeSource cs = classInstance.getProtectionDomain().getCodeSource(); return cs != null ? cs.getLocation() : null; } - public static File getClassLocation(Class classInstance) { - if (classInstance != null) { - return toFile(getClassLocationURL(classInstance)); - } else { + public static @Nullable File getClassLocation(@Nullable Class classInstance) { + if (classInstance == null) { return null; + } else { + return toFile(getClassLocationURL(classInstance)); } } - public static File getProjectRoot(Class classInstance) { + public static @Nullable File getProjectRoot(Class classInstance) { File file = getClassLocation(classInstance); return file != null ? file.getParentFile() : null; } - public static File toFile(URL url) { + public static @Nullable File toFile(@Nullable URL url) { URI uri = toURI(url); return uri != null ? new File(uri) : null; } - public static String toFileString(URL url) { + public static @Nullable String toFileString(@Nullable URL url) { File file = toFile(url); return file != null ? file.toString() : null; } - public static URI toURI(URL url) { + public static @Nullable URI toURI(@Nullable URL url) { try { if (url != null) { String protocol = url.getProtocol(); @@ -772,7 +776,9 @@ public static URI toURI(URL url) { * @return The current directory. */ public static File getCurrentDirectory() { - return new File(".").getAbsoluteFile().getParentFile(); + File result = new File(".").getAbsoluteFile().getParentFile(); + assert result != null : "@AssumeAssertion(nullness): this always works, even in the toplevel directory ..."; + return result; } /** @@ -791,7 +797,7 @@ public static File getTempDirectory() { * @param name The segment to validate. * @return The validated OS independent path segment in which each invalid sign is replaced. */ - public static String validateOSIndependentFileName(String name) { + public static @PolyNull String validateOSIndependentFileName(@PolyNull String name) { if (name != null) { char[] latinBig = StringUtil.LATIN_ALPHABET_BIG.toCharArray(); char[] latinSmall = StringUtil.LATIN_ALPHABET_SMALL.toCharArray(); diff --git a/key.util/src/main/java/org/key_project/util/java/NumberUtil.java b/key.util/src/main/java/org/key_project/util/java/NumberUtil.java index 76c34dac6f5..6c5fc2d0002 100644 --- a/key.util/src/main/java/org/key_project/util/java/NumberUtil.java +++ b/key.util/src/main/java/org/key_project/util/java/NumberUtil.java @@ -1,11 +1,13 @@ package org.key_project.util.java; +import org.jspecify.annotations.NullMarked; + /** * Provides utility methods to work with numbers. * * @author Martin Hentschel */ -@SuppressWarnings("nullness") +@NullMarked public class NumberUtil { /** * The maximal number of digits of an integer value. diff --git a/key.util/src/main/java/org/key_project/util/java/StringUtil.java b/key.util/src/main/java/org/key_project/util/java/StringUtil.java index 4a90df908ae..d37a213b2dd 100644 --- a/key.util/src/main/java/org/key_project/util/java/StringUtil.java +++ b/key.util/src/main/java/org/key_project/util/java/StringUtil.java @@ -111,7 +111,7 @@ public static boolean isTrimmedEmpty(@Nullable String text) { * @return The text in lower case or {@code null} if the given text is {@code null}. */ public static @PolyNull String toLowerCase(@PolyNull String text) { - return text != null ? text.toLowerCase() : null; + return text == null ? null : text.toLowerCase(); } /** diff --git a/key.util/src/main/java/org/key_project/util/java/WrapUtils.java b/key.util/src/main/java/org/key_project/util/java/WrapUtils.java index 09f264ef2f0..4d0328b5b36 100644 --- a/key.util/src/main/java/org/key_project/util/java/WrapUtils.java +++ b/key.util/src/main/java/org/key_project/util/java/WrapUtils.java @@ -1,5 +1,6 @@ package org.key_project.util.java; +import org.jspecify.annotations.NullMarked; /** * This class provides a simple routine that performs line wrapping of strings that may contain long @@ -13,7 +14,7 @@ * * @author Mattias Ulbrich, Mar 2021 */ -@SuppressWarnings("nullness") +@NullMarked public class WrapUtils { /* diff --git a/key.util/src/main/java/org/key_project/util/java/XMLUtil.java b/key.util/src/main/java/org/key_project/util/java/XMLUtil.java index f57110156c7..f65e3b76afe 100644 --- a/key.util/src/main/java/org/key_project/util/java/XMLUtil.java +++ b/key.util/src/main/java/org/key_project/util/java/XMLUtil.java @@ -1,5 +1,9 @@ package org.key_project.util.java; +import org.jspecify.annotations.NonNull; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; + import java.util.Map; import java.util.Map.Entry; @@ -8,7 +12,7 @@ * * @author Martin Hentschel */ -@SuppressWarnings("nullness") +@NullMarked public final class XMLUtil { /** * Attribute name to store encodings. @@ -33,7 +37,7 @@ private XMLUtil() { * @param replacer The {@link ITagReplacer} to use. * @return The new created text. */ - public static String replaceTags(String text, ITagReplacer replacer) { + public static @Nullable String replaceTags(@Nullable String text, @Nullable ITagReplacer replacer) { if (text != null && replacer != null) { StringBuilder sb = new StringBuilder(); char[] signs = text.toCharArray(); @@ -50,6 +54,7 @@ public static String replaceTags(String text, ITagReplacer replacer) { sb.append(sign); } } else { + assert tagSB != null : "@AssumeAssertion(nullness): tagSB must have been intialised already"; tagSB.append(sign); if (sign == '>' && !inAttribute) { inTag = false; @@ -81,7 +86,7 @@ public interface ITagReplacer { * @param tag The found tag. * @return The replacement to use or {@code null} to remove the tag. */ - String replaceTag(String tag); + @Nullable String replaceTag(String tag); } /** @@ -93,7 +98,7 @@ public interface ITagReplacer { */ public static class HTMLRendererReplacer implements ITagReplacer { @Override - public String replaceTag(String tag) { + public @Nullable String replaceTag(String tag) { if (tag.startsWith(" Date: Tue, 27 Jun 2023 08:13:34 +0200 Subject: [PATCH 10/37] nullness-specifying some more classes --- .../java/org/key_project/util/java/IntegerUtil.java | 4 +++- .../java/thread/AbstractRunnableWithException.java | 10 +++++++--- .../util/java/thread/AbstractRunnableWithResult.java | 11 +++++++---- .../util/java/thread/IRunnableWithException.java | 6 +++++- .../util/java/thread/IRunnableWithResult.java | 8 ++++++-- 5 files changed, 28 insertions(+), 11 deletions(-) diff --git a/key.util/src/main/java/org/key_project/util/java/IntegerUtil.java b/key.util/src/main/java/org/key_project/util/java/IntegerUtil.java index 1dd354bf163..3224fbd28a9 100644 --- a/key.util/src/main/java/org/key_project/util/java/IntegerUtil.java +++ b/key.util/src/main/java/org/key_project/util/java/IntegerUtil.java @@ -1,6 +1,8 @@ package org.key_project.util.java; -@SuppressWarnings("nullness") +import org.jspecify.annotations.NullMarked; + +@NullMarked public final class IntegerUtil { /** * Forbid instances. diff --git a/key.util/src/main/java/org/key_project/util/java/thread/AbstractRunnableWithException.java b/key.util/src/main/java/org/key_project/util/java/thread/AbstractRunnableWithException.java index adb9aa9ca68..4b8e210712d 100644 --- a/key.util/src/main/java/org/key_project/util/java/thread/AbstractRunnableWithException.java +++ b/key.util/src/main/java/org/key_project/util/java/thread/AbstractRunnableWithException.java @@ -1,5 +1,9 @@ package org.key_project.util.java.thread; +import org.checkerframework.checker.nullness.qual.MonotonicNonNull; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; + /** *

* Provides a basic implementation of {@link IRunnableWithException}. @@ -12,18 +16,18 @@ * @author Martin Hentschel * @see IRunnableWithResult */ -@SuppressWarnings("nullness") +@NullMarked public abstract class AbstractRunnableWithException implements IRunnableWithException { /** * An occurred exception. */ - private Exception exception; + private @MonotonicNonNull Exception exception; /** * {@inheritDoc} */ @Override - public Exception getException() { + public @Nullable Exception getException() { return exception; } diff --git a/key.util/src/main/java/org/key_project/util/java/thread/AbstractRunnableWithResult.java b/key.util/src/main/java/org/key_project/util/java/thread/AbstractRunnableWithResult.java index a05c67b1696..50422791a23 100644 --- a/key.util/src/main/java/org/key_project/util/java/thread/AbstractRunnableWithResult.java +++ b/key.util/src/main/java/org/key_project/util/java/thread/AbstractRunnableWithResult.java @@ -1,5 +1,8 @@ package org.key_project.util.java.thread; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; + /** *

* Provides a basic implementation of {@link IRunnableWithResult}. @@ -12,19 +15,19 @@ * @author Martin Hentschel * @see IRunnableWithResult */ -@SuppressWarnings("nullness") +@NullMarked public abstract class AbstractRunnableWithResult extends AbstractRunnableWithException implements IRunnableWithResult { /** * The result. */ - private T result; + private @Nullable T result; /** * {@inheritDoc} */ @Override - public T getResult() { + public @Nullable T getResult() { return result; } @@ -33,7 +36,7 @@ public T getResult() { * * @param result The result to set. */ - protected void setResult(T result) { + protected void setResult(@Nullable T result) { this.result = result; } } diff --git a/key.util/src/main/java/org/key_project/util/java/thread/IRunnableWithException.java b/key.util/src/main/java/org/key_project/util/java/thread/IRunnableWithException.java index 77e8c99d699..ef81e6bf5e6 100644 --- a/key.util/src/main/java/org/key_project/util/java/thread/IRunnableWithException.java +++ b/key.util/src/main/java/org/key_project/util/java/thread/IRunnableWithException.java @@ -1,5 +1,8 @@ package org.key_project.util.java.thread; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; + /** *

* A {@link Runnable} that has a result that is accessible via {@link #getResult()}. @@ -11,11 +14,12 @@ * @author Martin Hentschel * @see AbstractRunnableWithException */ +@NullMarked public interface IRunnableWithException extends Runnable { /** * Returns an occurred exception. * * @return An occurred exception. */ - Exception getException(); + @Nullable Exception getException(); } diff --git a/key.util/src/main/java/org/key_project/util/java/thread/IRunnableWithResult.java b/key.util/src/main/java/org/key_project/util/java/thread/IRunnableWithResult.java index c1d3d5f597a..6e431ff2e68 100644 --- a/key.util/src/main/java/org/key_project/util/java/thread/IRunnableWithResult.java +++ b/key.util/src/main/java/org/key_project/util/java/thread/IRunnableWithResult.java @@ -1,5 +1,8 @@ package org.key_project.util.java.thread; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; + /** *

* A {@link Runnable} that has a result that is accessible via {@link #getResult()}. @@ -11,18 +14,19 @@ * @author Martin Hentschel * @see AbstractRunnableWithResult */ +@NullMarked public interface IRunnableWithResult extends IRunnableWithException { /** * Returns the result. * * @return The result. */ - T getResult(); + @Nullable T getResult(); /** * Returns an occurred exception. * * @return An occurred exception. */ - Exception getException(); + @Nullable Exception getException(); } From c880594b490a7d2e74526188aa8cfd344f0c7a95 Mon Sep 17 00:00:00 2001 From: Mattias Ulbrich Date: Tue, 27 Jun 2023 14:59:10 +0200 Subject: [PATCH 11/37] nullness-specifying some more classes with Werner and Alexander --- .../java/org/key_project/util/ExtList.java | 2 +- .../util/collection/ImmutableList.java | 43 +++++++++++-------- .../util/collection/ImmutableSLList.java | 4 +- .../util/collection/Immutables.java | 17 +++++--- .../org/key_project/util/java/IOUtil.java | 1 + 5 files changed, 40 insertions(+), 27 deletions(-) diff --git a/key.util/src/main/java/org/key_project/util/ExtList.java b/key.util/src/main/java/org/key_project/util/ExtList.java index 5ef551fd969..f5836deb338 100644 --- a/key.util/src/main/java/org/key_project/util/ExtList.java +++ b/key.util/src/main/java/org/key_project/util/ExtList.java @@ -15,7 +15,7 @@ * Has facilities to get elements of a certain type ({@link #get(Class)}, {@link #collect(Class)}). */ @NullMarked -public class ExtList extends LinkedList { +public final class ExtList extends LinkedList { private static final long serialVersionUID = 9182017368310263908L; diff --git a/key.util/src/main/java/org/key_project/util/collection/ImmutableList.java b/key.util/src/main/java/org/key_project/util/collection/ImmutableList.java index 0b9aaceabe4..aeb853c3a95 100644 --- a/key.util/src/main/java/org/key_project/util/collection/ImmutableList.java +++ b/key.util/src/main/java/org/key_project/util/collection/ImmutableList.java @@ -1,24 +1,28 @@ package org.key_project.util.collection; +import org.checkerframework.checker.nullness.qual.EnsuresNonNullIf; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; + import java.util.*; import java.util.function.Function; import java.util.function.Predicate; import java.util.stream.Collector; import java.util.stream.Stream; import java.util.stream.StreamSupport; -import javax.annotation.Nonnull; /** * List interface to be implemented by non-destructive lists */ -public interface ImmutableList extends Iterable, java.io.Serializable { +@NullMarked +public interface ImmutableList extends Iterable, java.io.Serializable { /** * Returns a Collector that accumulates the input elements into a new ImmutableList. * * @return a Collector that accumulates the input elements into a new ImmutableList. */ - static Collector, ImmutableList> collector() { + static Collector, ImmutableList> collector() { return Collector.of(LinkedList::new, List::add, (list1, list2) -> { list1.addAll(list2); return list1; @@ -31,7 +35,7 @@ static Collector, ImmutableList> collector() { * @param list a List. * @return an ImmutableList containing the same elements as the specified list. */ - static ImmutableList fromList(Collection list) { + static ImmutableList fromList(Collection list) { ImmutableList result = ImmutableSLList.nil(); for (T el : list) { @@ -47,7 +51,7 @@ static ImmutableList fromList(Collection list) { * @return empty immutable list. * @param the entry type of the list. */ - static ImmutableList of() { + static ImmutableList of() { return ImmutableSLList.nil(); } @@ -58,7 +62,7 @@ static ImmutableList of() { * @return singleton immutable list. * @param the entry type of the list. */ - static ImmutableList of(T e1) { + static ImmutableList of(T e1) { return ImmutableSLList.singleton(e1); } @@ -71,7 +75,7 @@ static ImmutableList of(T e1) { * @return (e1, e2) as immutable list * @param the entry type of the list. */ - static ImmutableList of(T e1, T e2) { + static ImmutableList of(T e1, T e2) { return ImmutableSLList.singleton(e2).prepend(e1); } @@ -85,7 +89,7 @@ static ImmutableList of(T e1, T e2) { * @return (e1, e2, e3) as immutable list * @param the entry type of the list. */ - static ImmutableList of(T e1, T e2, T e3) { + static ImmutableList of(T e1, T e2, T e3) { return ImmutableSLList.singleton(e3).prepend(e2).prepend(e1); } @@ -97,7 +101,7 @@ static ImmutableList of(T e1, T e2, T e3) { * @return (e1, e2, e3, ...) as immutable list * @param the entry type of the list. */ - static ImmutableList of(T... es) { + static ImmutableList of(T... es) { ImmutableList result = ImmutableSLList.nil(); for (int i = es.length - 1; i >= 0; i--) { result = result.prepend(es[i]); @@ -178,7 +182,7 @@ static ImmutableList of(T... es) { /** * @return the first element in list */ - T head(); + @Nullable T head(); /** * return true if predicate is fullfilled for at least one element @@ -186,7 +190,7 @@ static ImmutableList of(T... es) { * @param predicate the predicate * @return true if predicate is fullfilled for at least one element */ - boolean exists(Predicate predicate); + boolean exists(Predicate predicate); /** * @return IList tail of list @@ -224,6 +228,7 @@ static ImmutableList of(T... es) { /** * @return true iff the list is empty */ + @EnsuresNonNullIf(expression = {"head()"}, result = false) boolean isEmpty(); /** @@ -243,12 +248,12 @@ static ImmutableList of(T... es) { /** * Convert the list to a Java array (O(n)) */ - S[] toArray(S[] array); + S[] toArray(S[] array); /** * Convert the list to a Java array (O(n)) */ - S[] toArray(Class type); + S[] toArray(Class type); /** @@ -283,7 +288,7 @@ default List toList() { * * @returns the filtered list */ - default @Nonnull ImmutableList filter(@Nonnull Predicate predicate) { + default ImmutableList filter(Predicate predicate) { return Immutables.filter(this, predicate); } @@ -295,7 +300,7 @@ default List toList() { * @param function a non-interfering, stateless function to apply to each element * @return the mapped list of the same length as this */ - default ImmutableList map(Function function) { + default ImmutableList map(Function function) { return Immutables.map(this, function); } @@ -303,7 +308,7 @@ default ImmutableList map(Function function) { * @param other prefix to check for * @return whether this list starts with the elements of the provided prefix */ - default boolean hasPrefix(ImmutableList other) { + default boolean hasPrefix(ImmutableList other) { if (other.size() > this.size()) { return false; } @@ -324,7 +329,7 @@ default boolean hasPrefix(ImmutableList other) { * @return new list with the prefix removed * @throws IllegalArgumentException if the provided prefix is not a prefix of this list */ - default ImmutableList stripPrefix(ImmutableList prefix) { + default ImmutableList stripPrefix(ImmutableList prefix) { if (prefix.isEmpty()) { return this; } @@ -348,7 +353,9 @@ default T last() { while (!remainder.tail().isEmpty()) { remainder = remainder.tail(); } - return remainder.head(); + T result = remainder.head(); + assert result != null : "@AssumeAssertion(nullness): this should never be null"; + return result; } } diff --git a/key.util/src/main/java/org/key_project/util/collection/ImmutableSLList.java b/key.util/src/main/java/org/key_project/util/collection/ImmutableSLList.java index e1bab0f04f2..21e9e74f989 100644 --- a/key.util/src/main/java/org/key_project/util/collection/ImmutableSLList.java +++ b/key.util/src/main/java/org/key_project/util/collection/ImmutableSLList.java @@ -259,7 +259,7 @@ public ImmutableList prependReverse(ImmutableList list) { * @return true if predicate is fullfilled for at least one element */ @Override - public boolean exists(Predicate predicate) { + public boolean exists(Predicate predicate) { ImmutableList list = this; while (!list.isEmpty()) { if (predicate.test(list.head())) { @@ -584,7 +584,7 @@ public boolean contains(S obj) { * @return true if predicate is fullfilled for at least one element */ @Override - public boolean exists(Predicate predicate) { + public boolean exists(Predicate predicate) { return false; } diff --git a/key.util/src/main/java/org/key_project/util/collection/Immutables.java b/key.util/src/main/java/org/key_project/util/collection/Immutables.java index b37b1c36729..543cfcc72d9 100644 --- a/key.util/src/main/java/org/key_project/util/collection/Immutables.java +++ b/key.util/src/main/java/org/key_project/util/collection/Immutables.java @@ -1,5 +1,8 @@ package org.key_project.util.collection; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; + import java.util.HashSet; import java.util.Set; import java.util.function.Function; @@ -13,7 +16,7 @@ * * @author Mattias Ulbrich */ -@SuppressWarnings("nullness") +@NullMarked public final class Immutables { private Immutables() { @@ -61,7 +64,7 @@ public static boolean isDuplicateFree(ImmutableList list) { * The implementation uses a hash set internally and thus runs in O(n). * * It reuses as much created datastructure as possible. In particular, if the list is already - * duplicate-fre, it does not allocate new memory (well, only temporarily) and returns the + * duplicate-free, it does not allocate new memory (well, only temporarily) and returns the * argument. * * Sidenote: Would that not make a nice KeY-Verification condition? Eat your own dogfood. @@ -88,6 +91,7 @@ public static ImmutableList removeDuplicates(ImmutableList list) { while (!stack.isEmpty()) { ImmutableList top = stack.head(); + assert !top.isEmpty() : "@AssumeAssertion(nullness)"; T element = top.head(); stack = stack.tail(); if (alreadySeen.contains(element)) { @@ -100,6 +104,7 @@ public static ImmutableList removeDuplicates(ImmutableList list) { while (!stack.isEmpty()) { ImmutableList top = stack.head(); + assert !top.isEmpty() : "@AssumeAssertion(nullness)"; T element = top.head(); stack = stack.tail(); if (!alreadySeen.contains(element)) { @@ -165,11 +170,11 @@ public static ImmutableList createListFrom(Iterable iterable) { * * @returns the filtered list */ - public static ImmutableList filter(ImmutableList ts, Predicate predicate) { + public static ImmutableList filter(ImmutableList ts, Predicate predicate) { // This must be a loop. A tail recursive implementation is not optimised // by the compiler and quickly leads to a stack overlow. ImmutableList acc = ImmutableSLList.nil(); - while (ts.size() > 0) { + while (!ts.isEmpty()) { T hd = ts.head(); if (predicate.test(hd)) { acc = acc.prepend(hd); @@ -188,11 +193,11 @@ public static ImmutableList filter(ImmutableList ts, Predicate pred * @param function a non-interfering, stateless function to apply to each element * @return the mapped list of the same length as this */ - public static ImmutableList map(ImmutableList ts, Function function) { + public static ImmutableList map(ImmutableList ts, Function function) { // This must be a loop. A tail recursive implementation is not optimised // by the compiler and quickly leads to a stack overlow. ImmutableList acc = ImmutableSLList.nil(); - while (ts.size() > 0) { + while (!ts.isEmpty()) { T hd = ts.head(); acc = acc.prepend(function.apply(hd)); ts = ts.tail(); diff --git a/key.util/src/main/java/org/key_project/util/java/IOUtil.java b/key.util/src/main/java/org/key_project/util/java/IOUtil.java index fe320f56351..47ab20593c6 100644 --- a/key.util/src/main/java/org/key_project/util/java/IOUtil.java +++ b/key.util/src/main/java/org/key_project/util/java/IOUtil.java @@ -745,6 +745,7 @@ public static boolean exists(File file) { return file != null ? file.toString() : null; } + @SuppressWarnings("nullness") public static @Nullable URI toURI(@Nullable URL url) { try { if (url != null) { From f489d15a972a5777224df5d0f086eed150396251 Mon Sep 17 00:00:00 2001 From: Mattias Ulbrich Date: Wed, 28 Jun 2023 07:55:33 +0200 Subject: [PATCH 12/37] nonnull: adding stub infrastructure --- build.gradle | 1 + .../src/main/checkerframework/java/net/URI.astub | 14 ++++++++++++++ .../java/org/key_project/util/java/IOUtil.java | 1 - 3 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 key.util/src/main/checkerframework/java/net/URI.astub diff --git a/build.gradle b/build.gradle index bcaf5563441..12c36ed7485 100644 --- a/build.gradle +++ b/build.gradle @@ -421,6 +421,7 @@ subprojects { extraJavacArgs = [ "-AonlyDefs=^org\\.key_project\\.util", "-Xmaxerrs", "10000", + "-Astubs=$projectDir/src/main/checkerframework", "-Werror", "-Aversion", ] diff --git a/key.util/src/main/checkerframework/java/net/URI.astub b/key.util/src/main/checkerframework/java/net/URI.astub new file mode 100644 index 00000000000..c4f24eb79e0 --- /dev/null +++ b/key.util/src/main/checkerframework/java/net/URI.astub @@ -0,0 +1,14 @@ +package java.net; + +import org.checkerframework.checker.nullness.qual.Nullable; +import org.checkerframework.framework.qual.AnnotatedFor; + +@AnnotatedFor("nullness") +public class URI { + + public URI(@Nullable String scheme, + @Nullable String userInfo, @Nullable String host, int port, + @Nullable String path, @Nullable String query, @Nullable String fragment) + throws URISyntaxException {} + +} diff --git a/key.util/src/main/java/org/key_project/util/java/IOUtil.java b/key.util/src/main/java/org/key_project/util/java/IOUtil.java index 47ab20593c6..fe320f56351 100644 --- a/key.util/src/main/java/org/key_project/util/java/IOUtil.java +++ b/key.util/src/main/java/org/key_project/util/java/IOUtil.java @@ -745,7 +745,6 @@ public static boolean exists(File file) { return file != null ? file.toString() : null; } - @SuppressWarnings("nullness") public static @Nullable URI toURI(@Nullable URL url) { try { if (url != null) { From edc3db2b4570db1e7256f9584f7fdb5b896bdf76 Mon Sep 17 00:00:00 2001 From: Mattias Ulbrich Date: Wed, 28 Jun 2023 08:19:21 +0200 Subject: [PATCH 13/37] nullness: continued to specify ImmutableList --- .../util/collection/ImmutableList.java | 1 + .../util/collection/ImmutableSLList.java | 44 +++++++++++++------ 2 files changed, 31 insertions(+), 14 deletions(-) diff --git a/key.util/src/main/java/org/key_project/util/collection/ImmutableList.java b/key.util/src/main/java/org/key_project/util/collection/ImmutableList.java index aeb853c3a95..29e9dc3f044 100644 --- a/key.util/src/main/java/org/key_project/util/collection/ImmutableList.java +++ b/key.util/src/main/java/org/key_project/util/collection/ImmutableList.java @@ -22,6 +22,7 @@ public interface ImmutableList extends Iterable, * * @return a Collector that accumulates the input elements into a new ImmutableList. */ + @SuppressWarnings("nullness") // it seems some annotations are missing on Collector.of ... static Collector, ImmutableList> collector() { return Collector.of(LinkedList::new, List::add, (list1, list2) -> { list1.addAll(list2); diff --git a/key.util/src/main/java/org/key_project/util/collection/ImmutableSLList.java b/key.util/src/main/java/org/key_project/util/collection/ImmutableSLList.java index 21e9e74f989..4fa77e0e523 100644 --- a/key.util/src/main/java/org/key_project/util/collection/ImmutableSLList.java +++ b/key.util/src/main/java/org/key_project/util/collection/ImmutableSLList.java @@ -1,5 +1,10 @@ package org.key_project.util.collection; +import org.checkerframework.checker.nullness.qual.EnsuresNonNullIf; +import org.jspecify.annotations.NonNull; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; + import java.lang.reflect.Array; import java.util.*; import java.util.function.BiConsumer; @@ -20,8 +25,9 @@ * and head with amortized O(1). This will be done later (if necessary). */ -@SuppressWarnings({ "unchecked", "nullness" }) -public abstract class ImmutableSLList implements ImmutableList { +@SuppressWarnings({ "unchecked" }) +@NullMarked +public abstract class ImmutableSLList implements ImmutableList { /** * generated serial id @@ -30,12 +36,12 @@ public abstract class ImmutableSLList implements ImmutableList { /** the empty list */ - public static ImmutableSLList nil() { + public static ImmutableSLList nil() { return (ImmutableSLList) NIL.NIL; } - public static ImmutableSLList singleton(T obj) { - return new Cons(obj, nil()); + public static ImmutableSLList singleton(T obj) { + return new Cons<>(obj, nil()); } /** @@ -60,7 +66,7 @@ public ImmutableList reverse() { * Convert the list to a Java array (O(n)) */ @Override - public S[] toArray(S[] array) { + public S[] toArray(S[] array) { S[] result; if (array.length < size()) { result = (S[]) Array.newInstance(array.getClass().getComponentType(), size()); @@ -79,11 +85,14 @@ public S[] toArray(S[] array) { * Convert the list to a Java array (O(n)) */ @Override - public S[] toArray(Class type) { + public S[] toArray(Class type) { S[] result = (S[]) Array.newInstance(type, size()); ImmutableList rest = this; for (int i = 0, sz = size(); i < sz; i++) { - result[i] = (S) rest.head(); + //@ assert !rest.isEmpty(); + @SuppressWarnings("nullness") + T head = rest.head(); + result[i] = type.cast(head); rest = rest.tail(); } return result; @@ -221,7 +230,10 @@ public ImmutableList prepend(ImmutableList list) { } else { final int sz = list.size(); if (sz == 1) { - return new Cons<>(list.head(), this); + //@ assert !list.isEmpty(); + @SuppressWarnings("nullness") + @NonNull S head = list.head(); + return new Cons<>(head, this); } Cons result = this; final Object[] listElements = list.toArray(new Object[sz]); @@ -245,6 +257,7 @@ public ImmutableList prependReverse(ImmutableList list) { } else { Cons result = this; for (int sz = list.size(); sz > 0; sz--) { + assert !list.isEmpty() : "@AssumeAssertion(nullness): Invariant"; result = new Cons<>(list.head(), result); list = list.tail(); } @@ -365,6 +378,7 @@ public boolean contains(S obj) { /** @return true iff the list is empty */ @Override + @EnsuresNonNullIf(expression = {"head()"}, result = false) public boolean isEmpty() { return false; } @@ -424,7 +438,7 @@ public ImmutableList removeAll(S obj) { @Override - public boolean equals(Object o) { + public boolean equals(@Nullable Object o) { if (!(o instanceof ImmutableList)) { return false; } @@ -462,7 +476,7 @@ public String toString() { } /** iterates through a none destructive list */ - private static class SLListIterator implements Iterator { + private static class SLListIterator implements Iterator { /** the list of remaining elements */ private ImmutableList list; @@ -479,6 +493,7 @@ public SLListIterator(ImmutableList list) { /** @return next element in list */ @Override public T next() { + // TODO Perhaps add a RT and throw NuSuchElement to make type checker happy. final T element = list.head(); list = list.tail(); return element; @@ -533,7 +548,7 @@ public int size() { } @Override - public boolean equals(Object o) { + public boolean equals(@Nullable Object o) { return o instanceof NIL; } @@ -589,6 +604,7 @@ public boolean exists(Predicate predicate) { } @Override + @EnsuresNonNullIf(expression = {"head()"}, result = false) public boolean isEmpty() { return true; } @@ -599,7 +615,7 @@ public Iterator iterator() { } @Override - public S head() { + public @Nullable S head() { return null; } @@ -635,7 +651,7 @@ public SLNilListIterator() { /** @return next element in list */ @Override public S next() { - return null; + throw new NoSuchElementException(); } /** From b5b6455d226c8e1ab526359296a5b33c8e7dd9ee Mon Sep 17 00:00:00 2001 From: Mattias Ulbrich Date: Wed, 28 Jun 2023 14:10:46 +0200 Subject: [PATCH 14/37] more nullness specifications. --- build.gradle | 24 +++++++++---------- key.util/build.gradle | 13 ++++++++++ .../java/org/key_project/util/LRUCache.java | 4 +++- .../util/collection/ImmutableList.java | 4 ++-- .../util/collection/ImmutableSLList.java | 23 +++++++++++------- .../org/key_project/util/java/IOUtil.java | 7 +++++- .../util/reflection/ClassLoaderUtil.java | 4 +++- .../util/reflection/IClassLoader.java | 3 +++ .../JavaApplicationClassLoader.java | 4 +++- 9 files changed, 59 insertions(+), 27 deletions(-) diff --git a/build.gradle b/build.gradle index 12c36ed7485..61b819bb947 100644 --- a/build.gradle +++ b/build.gradle @@ -414,18 +414,18 @@ subprojects { } } - checkerFramework { - checkers = [ - "org.checkerframework.checker.nullness.NullnessChecker", - ] - extraJavacArgs = [ - "-AonlyDefs=^org\\.key_project\\.util", - "-Xmaxerrs", "10000", - "-Astubs=$projectDir/src/main/checkerframework", - "-Werror", - "-Aversion", - ] - } +// checkerFramework { +// checkers = [ +// "org.checkerframework.checker.nullness.NullnessChecker", +// ] +// extraJavacArgs = [ +// "-AonlyDefs=^org\\.key_project\\.util", +// "-Xmaxerrs", "10000", +// "-Astubs=$projectDir/src/main/checkerframework", +// "-Werror", +// "-Aversion", +// ] +// } } task start { diff --git a/key.util/build.gradle b/key.util/build.gradle index ba8522bb871..3cbc8f1ed38 100644 --- a/key.util/build.gradle +++ b/key.util/build.gradle @@ -1,2 +1,15 @@ dependencies{ } + +checkerFramework { + checkers = [ + "org.checkerframework.checker.nullness.NullnessChecker", + ] + extraJavacArgs = [ + "-AonlyDefs=^org\\.key_project\\.util", + "-Xmaxerrs", "10000", + "-Astubs=$projectDir/src/main/checkerframework", + "-Werror", + "-Aversion", + ] +} \ No newline at end of file diff --git a/key.util/src/main/java/org/key_project/util/LRUCache.java b/key.util/src/main/java/org/key_project/util/LRUCache.java index 3488b9d6db4..81275fae291 100644 --- a/key.util/src/main/java/org/key_project/util/LRUCache.java +++ b/key.util/src/main/java/org/key_project/util/LRUCache.java @@ -1,12 +1,14 @@ package org.key_project.util; +import org.jspecify.annotations.NullMarked; + import java.util.LinkedHashMap; import java.util.Map; /** * Simple realisation of an LRU cache. */ -@SuppressWarnings("nullness") +@NullMarked public class LRUCache extends LinkedHashMap { /** diff --git a/key.util/src/main/java/org/key_project/util/collection/ImmutableList.java b/key.util/src/main/java/org/key_project/util/collection/ImmutableList.java index 29e9dc3f044..5e402613779 100644 --- a/key.util/src/main/java/org/key_project/util/collection/ImmutableList.java +++ b/key.util/src/main/java/org/key_project/util/collection/ImmutableList.java @@ -183,7 +183,7 @@ public interface ImmutableList extends Iterable, /** * @return the first element in list */ - @Nullable T head(); + T head(); /** * return true if predicate is fullfilled for at least one element @@ -229,7 +229,7 @@ public interface ImmutableList extends Iterable, /** * @return true iff the list is empty */ - @EnsuresNonNullIf(expression = {"head()"}, result = false) + // not true: @EnsuresNonNullIf(expression = {"head()"}, result = false) boolean isEmpty(); /** diff --git a/key.util/src/main/java/org/key_project/util/collection/ImmutableSLList.java b/key.util/src/main/java/org/key_project/util/collection/ImmutableSLList.java index 4fa77e0e523..4816e38e4e3 100644 --- a/key.util/src/main/java/org/key_project/util/collection/ImmutableSLList.java +++ b/key.util/src/main/java/org/key_project/util/collection/ImmutableSLList.java @@ -4,6 +4,8 @@ import org.jspecify.annotations.NonNull; import org.jspecify.annotations.NullMarked; import org.jspecify.annotations.Nullable; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.lang.reflect.Array; import java.util.*; @@ -12,6 +14,7 @@ import java.util.function.Function; import java.util.function.Predicate; import java.util.function.Supplier; +import java.util.logging.LogManager; import java.util.stream.Collector; /** @@ -33,7 +36,7 @@ public abstract class ImmutableSLList implements Imm * generated serial id */ private static final long serialVersionUID = 8717813038177120287L; - + private static final Logger log = LoggerFactory.getLogger(ImmutableSLList.NIL.class); /** the empty list */ public static ImmutableSLList nil() { @@ -69,7 +72,9 @@ public ImmutableList reverse() { public S[] toArray(S[] array) { S[] result; if (array.length < size()) { - result = (S[]) Array.newInstance(array.getClass().getComponentType(), size()); + Class arrayClass = array.getClass(); + assert arrayClass.isArray() : "@AssumeAssertion(nullness): This has indeed a component type"; + result = (S[]) Array.newInstance(arrayClass.getComponentType(), size()); } else { result = array; } @@ -85,14 +90,14 @@ public ImmutableList reverse() { * Convert the list to a Java array (O(n)) */ @Override + @SuppressWarnings("nullness") public S[] toArray(Class type) { S[] result = (S[]) Array.newInstance(type, size()); ImmutableList rest = this; for (int i = 0, sz = size(); i < sz; i++) { //@ assert !rest.isEmpty(); - @SuppressWarnings("nullness") T head = rest.head(); - result[i] = type.cast(head); + result[i] = (S)type.cast(head); rest = rest.tail(); } return result; @@ -169,7 +174,7 @@ public ImmutableList take(int n) { } - private static class Cons extends ImmutableSLList { + private static class Cons extends ImmutableSLList { /** * @@ -378,7 +383,6 @@ public boolean contains(S obj) { /** @return true iff the list is empty */ @Override - @EnsuresNonNullIf(expression = {"head()"}, result = false) public boolean isEmpty() { return false; } @@ -604,7 +608,6 @@ public boolean exists(Predicate predicate) { } @Override - @EnsuresNonNullIf(expression = {"head()"}, result = false) public boolean isEmpty() { return true; } @@ -615,8 +618,10 @@ public Iterator iterator() { } @Override - public @Nullable S head() { - return null; + public S head() { + NoSuchElementException ex = new NoSuchElementException(); + log.error("head on NIL!", ex); + throw ex; } @Override diff --git a/key.util/src/main/java/org/key_project/util/java/IOUtil.java b/key.util/src/main/java/org/key_project/util/java/IOUtil.java index fe320f56351..2d1af385628 100644 --- a/key.util/src/main/java/org/key_project/util/java/IOUtil.java +++ b/key.util/src/main/java/org/key_project/util/java/IOUtil.java @@ -1,6 +1,7 @@ package org.key_project.util.java; import org.checkerframework.checker.nullness.qual.PolyNull; +import org.jspecify.annotations.NonNull; import org.jspecify.annotations.NullMarked; import org.jspecify.annotations.Nullable; @@ -843,7 +844,11 @@ public static void extractZip(InputStream in, Path targetDir) throws IOException Files.createDirectories(path); } else { // create nonexistent parent directories and then extract the file - Files.createDirectories(path.getParent()); + // Since path is the result of resolving a zip entry name in the + // target directory, it does have a parent. + @SuppressWarnings("nullness") + @NonNull Path parent = path.getParent(); + Files.createDirectories(parent); Files.copy(zin, path); } } diff --git a/key.util/src/main/java/org/key_project/util/reflection/ClassLoaderUtil.java b/key.util/src/main/java/org/key_project/util/reflection/ClassLoaderUtil.java index b58cab00727..8f18b11d311 100644 --- a/key.util/src/main/java/org/key_project/util/reflection/ClassLoaderUtil.java +++ b/key.util/src/main/java/org/key_project/util/reflection/ClassLoaderUtil.java @@ -1,5 +1,7 @@ package org.key_project.util.reflection; +import org.jspecify.annotations.NullMarked; + import java.util.ServiceLoader; /** @@ -35,7 +37,7 @@ * @see IClassLoader * @see JavaApplicationClassLoader */ -@SuppressWarnings("nullness") +@NullMarked public class ClassLoaderUtil { /** * The {@link IClassLoader} instance to use. diff --git a/key.util/src/main/java/org/key_project/util/reflection/IClassLoader.java b/key.util/src/main/java/org/key_project/util/reflection/IClassLoader.java index e45595392a6..3dcbba42b97 100644 --- a/key.util/src/main/java/org/key_project/util/reflection/IClassLoader.java +++ b/key.util/src/main/java/org/key_project/util/reflection/IClassLoader.java @@ -1,5 +1,7 @@ package org.key_project.util.reflection; +import org.jspecify.annotations.NullMarked; + import java.util.ServiceLoader; /** @@ -11,6 +13,7 @@ * @author Martin Hentschel * @see ClassLoaderUtil */ +@NullMarked public interface IClassLoader { /** * Returns the {@link Class} for the given class name similar to {@link Class#forName(String)}. diff --git a/key.util/src/main/java/org/key_project/util/reflection/JavaApplicationClassLoader.java b/key.util/src/main/java/org/key_project/util/reflection/JavaApplicationClassLoader.java index 38feed62992..37b18eb5512 100644 --- a/key.util/src/main/java/org/key_project/util/reflection/JavaApplicationClassLoader.java +++ b/key.util/src/main/java/org/key_project/util/reflection/JavaApplicationClassLoader.java @@ -1,5 +1,7 @@ package org.key_project.util.reflection; +import org.jspecify.annotations.NullMarked; + import java.util.ServiceLoader; /** @@ -10,7 +12,7 @@ * * @author Martin Hentschel */ -@SuppressWarnings("nullness") +@NullMarked public class JavaApplicationClassLoader implements IClassLoader { /** * {@inheritDoc} From c9b24c5c9c08ac0ad0ca8b11fb14c0ce30df3b76 Mon Sep 17 00:00:00 2001 From: Mattias Ulbrich Date: Wed, 28 Jun 2023 14:10:58 +0200 Subject: [PATCH 15/37] wip --- .../java/org/key_project/util/java/ArrayUtil.java | 15 ++++++++++----- .../java/org/key_project/util/model/ClassA.java | 2 +- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/key.util/src/main/java/org/key_project/util/java/ArrayUtil.java b/key.util/src/main/java/org/key_project/util/java/ArrayUtil.java index 03e635d16df..2ce18fcbbd2 100644 --- a/key.util/src/main/java/org/key_project/util/java/ArrayUtil.java +++ b/key.util/src/main/java/org/key_project/util/java/ArrayUtil.java @@ -1,5 +1,8 @@ package org.key_project.util.java; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; + import java.util.LinkedList; import java.util.List; import java.util.Objects; @@ -10,7 +13,7 @@ * * @author Martin Hentschel */ -@SuppressWarnings("nullness") +@NullMarked public final class ArrayUtil { /** * Forbid instances by this private constructor. @@ -21,11 +24,13 @@ private ArrayUtil() { /** * Searches an element in the given {@link Iterable} instance. * + * Returns the first element that satisfies the predicate. + * * @param array The instance to search in. * @param filter The filter to select an element. * @return The found element or {@code null} if no element was found. */ - public static T search(T[] array, Predicate filter) { + public static @Nullable T search(T[] array, Predicate filter) { T result = null; if (array != null && filter != null) { int i = 0; @@ -55,7 +60,7 @@ public static T search(T[] array, Predicate filter) { * @throws IllegalArgumentException Both parameters are {@code null}. */ @SuppressWarnings("unchecked") - public static T[] addAll(T[] array, T[] toAdd) { + public static T [] addAll(T @Nullable [] array, T @Nullable [] toAdd) { if (array != null) { if (toAdd != null) { T[] result = @@ -100,7 +105,7 @@ public static T[] addAll(T[] array, T[] toAdd) { * @throws IllegalArgumentException Both parameters are {@code null}. */ @SuppressWarnings("unchecked") - public static T[] addAll(T[] array, T[] toAdd, Class newArrayType) { + public static T[] addAll(T @Nullable [] array, T @Nullable [] toAdd, Class newArrayType) { if (array != null) { if (toAdd != null) { T[] result = (T[]) java.lang.reflect.Array.newInstance(newArrayType, @@ -140,7 +145,7 @@ public static T[] addAll(T[] array, T[] toAdd, Class newArrayType) { * @throws IllegalArgumentException Both parameters are {@code null}. */ @SuppressWarnings("unchecked") - public static T[] add(T[] array, T toAdd) { + public static T[] add(T @Nullable [] array, @Nullable T toAdd) { if (array != null) { T[] result = (T[]) java.lang.reflect.Array .newInstance(array.getClass().getComponentType(), array.length + 1); diff --git a/key.util/src/test/java/org/key_project/util/model/ClassA.java b/key.util/src/test/java/org/key_project/util/model/ClassA.java index 3e71633c94a..8d47e38cdda 100644 --- a/key.util/src/test/java/org/key_project/util/model/ClassA.java +++ b/key.util/src/test/java/org/key_project/util/model/ClassA.java @@ -1,6 +1,6 @@ package org.key_project.util.model; -@SuppressWarnings("unused") +@SuppressWarnings({"unused", "nullness"}) public class ClassA { private final int privateField = 1; From 6280b57fd8c284b75fbe5b11141f2f38cbeecd6d Mon Sep 17 00:00:00 2001 From: Mattias Ulbrich Date: Thu, 6 Jul 2023 14:57:53 +0200 Subject: [PATCH 16/37] nullness checks for ArrayUtil, Beans --- .../java/org/key_project/util/bean/Bean.java | 10 +++-- .../java/org/key_project/util/bean/IBean.java | 3 ++ .../org/key_project/util/java/ArrayUtil.java | 41 ++++++++++++------- 3 files changed, 36 insertions(+), 18 deletions(-) diff --git a/key.util/src/main/java/org/key_project/util/bean/Bean.java b/key.util/src/main/java/org/key_project/util/bean/Bean.java index 04c5899a2ca..9eae6c0cb14 100644 --- a/key.util/src/main/java/org/key_project/util/bean/Bean.java +++ b/key.util/src/main/java/org/key_project/util/bean/Bean.java @@ -6,6 +6,9 @@ import org.key_project.util.java.ArrayUtil; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; + /** * Implements the basic methods that a Java bean should have and is the default implementation of * {@link IBean}. @@ -13,11 +16,12 @@ * @author Martin Hentschel * @see IBean */ -@SuppressWarnings("nullness") +@NullMarked public class Bean implements IBean { /** * The used {@link PropertyChangeSupport}. */ + @SuppressWarnings("nullness") // TODO Check with Werner Dietl why this is so. private final PropertyChangeSupport pcs = new PropertyChangeSupport(this); /** @@ -127,8 +131,8 @@ protected void fireIndexedPropertyChange(String propertyName, int index, int old * @param oldValue The old value. * @param newValue The new value. */ - protected void fireIndexedPropertyChange(String propertyName, int index, Object oldValue, - Object newValue) { + protected void fireIndexedPropertyChange(String propertyName, int index, + @Nullable Object oldValue, @Nullable Object newValue) { pcs.fireIndexedPropertyChange(propertyName, index, oldValue, newValue); } diff --git a/key.util/src/main/java/org/key_project/util/bean/IBean.java b/key.util/src/main/java/org/key_project/util/bean/IBean.java index 1706fcd6b16..ff71eb17169 100644 --- a/key.util/src/main/java/org/key_project/util/bean/IBean.java +++ b/key.util/src/main/java/org/key_project/util/bean/IBean.java @@ -2,6 +2,8 @@ import java.beans.PropertyChangeListener; +import org.jspecify.annotations.NullMarked; + /** *

* Defines the methods that a Java bean must have. @@ -13,6 +15,7 @@ * @author Martin Hentschel * @see Bean */ +@NullMarked public interface IBean { /** * Adds the given listener. diff --git a/key.util/src/main/java/org/key_project/util/java/ArrayUtil.java b/key.util/src/main/java/org/key_project/util/java/ArrayUtil.java index 2ce18fcbbd2..5c5d780b656 100644 --- a/key.util/src/main/java/org/key_project/util/java/ArrayUtil.java +++ b/key.util/src/main/java/org/key_project/util/java/ArrayUtil.java @@ -1,13 +1,13 @@ package org.key_project.util.java; -import org.jspecify.annotations.NullMarked; -import org.jspecify.annotations.Nullable; - import java.util.LinkedList; import java.util.List; import java.util.Objects; import java.util.function.Predicate; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; + /** * Provides static methods to work with arrays. * @@ -60,25 +60,26 @@ private ArrayUtil() { * @throws IllegalArgumentException Both parameters are {@code null}. */ @SuppressWarnings("unchecked") - public static T [] addAll(T @Nullable [] array, T @Nullable [] toAdd) { + public static T[] addAll(T @Nullable [] array, + T @Nullable [] toAdd) { if (array != null) { if (toAdd != null) { T[] result = - (T[]) java.lang.reflect.Array.newInstance(array.getClass().getComponentType(), + (T[]) java.lang.reflect.Array.newInstance(getComponentType(array), array.length + toAdd.length); System.arraycopy(array, 0, result, 0, array.length); System.arraycopy(toAdd, 0, result, array.length, toAdd.length); return result; } else { T[] result = (T[]) java.lang.reflect.Array - .newInstance(array.getClass().getComponentType(), array.length); + .newInstance(getComponentType(array), array.length); System.arraycopy(array, 0, result, 0, array.length); return result; } } else { if (toAdd != null) { T[] result = (T[]) java.lang.reflect.Array - .newInstance(toAdd.getClass().getComponentType(), toAdd.length); + .newInstance(getComponentType(toAdd), toAdd.length); System.arraycopy(toAdd, 0, result, 0, toAdd.length); return result; } else { @@ -88,6 +89,12 @@ private ArrayUtil() { } } + private static Class getComponentType(T[] array) { + Class arrayClass = array.getClass(); + assert arrayClass.isArray() : "@AssumeAssertion(nullness): This is always the case"; + return (Class) arrayClass.getComponentType(); + } + /** *

* Adds the given elements to the existing array. The result is a new array that contains the @@ -105,7 +112,8 @@ private ArrayUtil() { * @throws IllegalArgumentException Both parameters are {@code null}. */ @SuppressWarnings("unchecked") - public static T[] addAll(T @Nullable [] array, T @Nullable [] toAdd, Class newArrayType) { + public static T[] addAll(T @Nullable [] array, + T @Nullable [] toAdd, Class newArrayType) { if (array != null) { if (toAdd != null) { T[] result = (T[]) java.lang.reflect.Array.newInstance(newArrayType, @@ -145,10 +153,12 @@ private ArrayUtil() { * @throws IllegalArgumentException Both parameters are {@code null}. */ @SuppressWarnings("unchecked") - public static T[] add(T @Nullable [] array, @Nullable T toAdd) { + public static @Nullable T[] add(T @Nullable [] array, + @Nullable T toAdd) { if (array != null) { - T[] result = (T[]) java.lang.reflect.Array - .newInstance(array.getClass().getComponentType(), array.length + 1); + @Nullable + T[] result = (@Nullable T[]) java.lang.reflect.Array + .newInstance(getComponentType(array), array.length + 1); System.arraycopy(array, 0, result, 0, array.length); result[array.length] = toAdd; return result; @@ -200,7 +210,7 @@ public static int[] add(int[] array, int toAdd) { public static T[] insert(T[] array, T toInsert, int index) { if (array != null) { T[] result = (T[]) java.lang.reflect.Array - .newInstance(array.getClass().getComponentType(), array.length + 1); + .newInstance(getComponentType(array), array.length + 1); if (index >= 1) { System.arraycopy(array, 0, result, 0, index); } @@ -263,7 +273,8 @@ public static int indexOf(T[] array, T toSearch) { * was {@code null}. */ @SuppressWarnings("unchecked") - public static T[] remove(T[] array, T toRemove) { + public static T @Nullable [] remove(T @Nullable [] array, + @Nullable T toRemove) { if (array != null) { List result = new LinkedList<>(); for (T element : array) { @@ -271,8 +282,8 @@ public static T[] remove(T[] array, T toRemove) { result.add(element); } } - return result.toArray((T[]) java.lang.reflect.Array - .newInstance(array.getClass().getComponentType(), result.size())); + return (T[]) result.toArray((T[]) java.lang.reflect.Array + .newInstance(getComponentType(array), result.size())); } else { return null; } From a1b4bd171cc779df7ad712c51c0a73c549f58739 Mon Sep 17 00:00:00 2001 From: Mattias Ulbrich Date: Thu, 6 Jul 2023 15:01:31 +0200 Subject: [PATCH 17/37] nullness and refactoring of class ImmutableSet --- .../nparser/builder/DeclarationBuilder.java | 6 +-- .../key/nparser/builder/TacletPBuilder.java | 7 +-- .../de/uka/ilkd/key/proof/io/KeYFile.java | 5 +- .../util/collection/DefaultImmutableSet.java | 52 +++++-------------- .../util/collection/ImmutableSet.java | 40 +++++--------- .../util/collection/Immutables.java | 39 +++++++++----- .../util/collection/NotUniqueException.java | 9 ++-- 7 files changed, 64 insertions(+), 94 deletions(-) diff --git a/key.core/src/main/java/de/uka/ilkd/key/nparser/builder/DeclarationBuilder.java b/key.core/src/main/java/de/uka/ilkd/key/nparser/builder/DeclarationBuilder.java index 1b8083dfbdf..9b3a8602c94 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/nparser/builder/DeclarationBuilder.java +++ b/key.core/src/main/java/de/uka/ilkd/key/nparser/builder/DeclarationBuilder.java @@ -15,8 +15,8 @@ import de.uka.ilkd.key.nparser.ParsingFacade; import de.uka.ilkd.key.rule.RuleSet; -import org.key_project.util.collection.DefaultImmutableSet; import org.key_project.util.collection.ImmutableSet; +import org.key_project.util.collection.Immutables; import org.antlr.v4.runtime.Token; @@ -119,9 +119,9 @@ public Object visitOne_sort_decl(KeYParser.One_sort_declContext ctx) { Name sortName = new Name(sortId); ImmutableSet ext = sortExt == null ? ImmutableSet.empty() - : DefaultImmutableSet.fromCollection(sortExt); + : Immutables.createSetFrom(sortExt); ImmutableSet oneOf = sortOneOf == null ? ImmutableSet.empty() - : DefaultImmutableSet.fromCollection(sortOneOf); + : Immutables.createSetFrom(sortOneOf); // attention: no expand to java.lang here! if (sorts().lookup(sortName) == null) { diff --git a/key.core/src/main/java/de/uka/ilkd/key/nparser/builder/TacletPBuilder.java b/key.core/src/main/java/de/uka/ilkd/key/nparser/builder/TacletPBuilder.java index b54eee5a0a8..2e3fdcf0878 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/nparser/builder/TacletPBuilder.java +++ b/key.core/src/main/java/de/uka/ilkd/key/nparser/builder/TacletPBuilder.java @@ -25,10 +25,7 @@ import de.uka.ilkd.key.rule.tacletbuilder.*; import de.uka.ilkd.key.util.parsing.BuildingException; -import org.key_project.util.collection.DefaultImmutableSet; -import org.key_project.util.collection.ImmutableList; -import org.key_project.util.collection.ImmutableSLList; -import org.key_project.util.collection.ImmutableSet; +import org.key_project.util.collection.*; import antlr.RecognitionException; import org.antlr.v4.runtime.ParserRuleContext; @@ -452,7 +449,7 @@ public Object visitAddrules(KeYParser.AddrulesContext ctx) { @Override public ImmutableSet visitAddprogvar(KeYParser.AddprogvarContext ctx) { final Collection accept = accept(ctx.pvs); - return ImmutableSet.fromSet(new HashSet<>(Objects.requireNonNull(accept))); + return Immutables.createSetFrom(Objects.requireNonNull(accept)); } @Override diff --git a/key.core/src/main/java/de/uka/ilkd/key/proof/io/KeYFile.java b/key.core/src/main/java/de/uka/ilkd/key/proof/io/KeYFile.java index 29adb3191c7..59e2b95f8c7 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/proof/io/KeYFile.java +++ b/key.core/src/main/java/de/uka/ilkd/key/proof/io/KeYFile.java @@ -33,6 +33,7 @@ import org.key_project.util.collection.DefaultImmutableSet; import org.key_project.util.collection.ImmutableSet; +import org.key_project.util.collection.Immutables; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -328,8 +329,8 @@ public ImmutableSet readContracts() { ContractsAndInvariantsFinder cinvs = new ContractsAndInvariantsFinder(initConfig.getServices(), initConfig.namespaces()); getParseContext().accept(cinvs); - specRepos.addContracts(ImmutableSet.fromCollection(cinvs.getContracts())); - specRepos.addClassInvariants(ImmutableSet.fromCollection(cinvs.getInvariants())); + specRepos.addContracts(Immutables.createSetFrom(cinvs.getContracts())); + specRepos.addClassInvariants(Immutables.createSetFrom(cinvs.getInvariants())); return DefaultImmutableSet.nil(); } diff --git a/key.util/src/main/java/org/key_project/util/collection/DefaultImmutableSet.java b/key.util/src/main/java/org/key_project/util/collection/DefaultImmutableSet.java index 486f3988989..14b81dc14ea 100644 --- a/key.util/src/main/java/org/key_project/util/collection/DefaultImmutableSet.java +++ b/key.util/src/main/java/org/key_project/util/collection/DefaultImmutableSet.java @@ -1,13 +1,14 @@ package org.key_project.util.collection; -import java.util.Collection; import java.util.HashSet; import java.util.Iterator; import java.util.Set; import java.util.function.Predicate; import java.util.stream.Stream; import java.util.stream.StreamSupport; -import javax.annotation.Nullable; + +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; /** * implementation of a persistent set using the SLListOf implementation with all its implications @@ -15,8 +16,8 @@ * * @param type of object to store */ -@SuppressWarnings("nullness") -public class DefaultImmutableSet implements ImmutableSet { +@NullMarked +public class DefaultImmutableSet implements ImmutableSet { /** * @@ -33,7 +34,7 @@ public class DefaultImmutableSet implements ImmutableSet { /** the empty set */ @SuppressWarnings("unchecked") - public static final DefaultImmutableSet nil() { + public static DefaultImmutableSet nil() { return (DefaultImmutableSet) NILSet.NIL; } @@ -46,7 +47,7 @@ protected DefaultImmutableSet() { * * @param element of type the new Set contains */ - protected DefaultImmutableSet(T element) { + private DefaultImmutableSet(T element) { elementList = (ImmutableSLList.nil()).prepend(element); } @@ -229,7 +230,7 @@ public ImmutableSet remove(T element) { * @return true iff the this set is subset of o and vice versa. */ @Override - public boolean equals(Object obj) { + public boolean equals(@Nullable Object obj) { if (obj == this) { return true; } @@ -284,7 +285,8 @@ public ImmutableList toImmutableList() { * @param list a non-null immutable list * @return a fresh immutable set with the same iteration order. */ - public static ImmutableSet fromImmutableList(ImmutableList list) { + public static ImmutableSet fromImmutableList( + ImmutableList list) { if (list.isEmpty()) { return nil(); } else { @@ -292,36 +294,6 @@ public static ImmutableSet fromImmutableList(ImmutableList list) { } } - /** - * Create an immutable set from a mutable set - * - * @param set a non-null mutable set - * @return a fresh immutable set with all the elements in set - */ - public static ImmutableSet fromSet(@Nullable Set set) { - if (set == null) { - return null; - } - if (set.isEmpty()) { - return nil(); - } else { - ImmutableList backerList = ImmutableSLList.nil(); - for (T element : set) { - backerList = backerList.prepend(element); - } - return new DefaultImmutableSet<>(backerList); - } - } - - - public static ImmutableSet fromCollection(@Nullable Collection seq) { - if (seq == null) { - return null; - } - return fromSet(new HashSet<>(seq)); - } - - @Override public String toString() { Iterator it = this.iterator(); @@ -407,10 +379,10 @@ public boolean isEmpty() { } /** - * @return true iff the this set is subset of o and vice versa. + * @return true iff this set is subset of o and vice versa. */ @Override - public boolean equals(Object o) { + public boolean equals(@Nullable Object o) { return o instanceof NILSet; } diff --git a/key.util/src/main/java/org/key_project/util/collection/ImmutableSet.java b/key.util/src/main/java/org/key_project/util/collection/ImmutableSet.java index 6264ae12d9d..4b34c059f15 100644 --- a/key.util/src/main/java/org/key_project/util/collection/ImmutableSet.java +++ b/key.util/src/main/java/org/key_project/util/collection/ImmutableSet.java @@ -5,61 +5,45 @@ import java.util.stream.Collector; import java.util.stream.Collector.Characteristics; import java.util.stream.Stream; -import javax.annotation.Nonnull; + +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; /** * interface implemented by non-destructive Sets. CONVENTION: Each SetOf implementation has to * offer a public static final variable .nil() */ -@SuppressWarnings("nullness") -public interface ImmutableSet extends Iterable, java.io.Serializable { +@NullMarked +public interface ImmutableSet + extends Iterable, java.io.Serializable { /** * Returns a Collector that accumulates the input elements into a new ImmutableSet. * * @return a Collector that accumulates the input elements into a new ImmutableSet. */ - static Collector, ImmutableSet> collector() { + @SuppressWarnings("nullness") // it seems some annotations are missing on Collector.of ... + static Collector, ImmutableSet> collector() { return Collector.of(HashSet::new, Set::add, (set1, set2) -> { set1.addAll(set2); return set1; - }, ImmutableSet::fromSet, Characteristics.UNORDERED); - } - - /** - * Creates an ImmutableSet from a Set. - * - * @param set a Set. - * @return an ImmutableSet containing the same elements as the specified set. - */ - static ImmutableSet fromSet(Set set) { - ImmutableSet result = DefaultImmutableSet.nil(); - - for (T el : set) { - result = result.add(el); - } - - return result; + }, Immutables::createSetFrom, Characteristics.UNORDERED); } /** * Builds a single set with the given obj. */ - static ImmutableSet singleton(T obj) { + static ImmutableSet singleton(T obj) { ImmutableSet result = DefaultImmutableSet.nil(); return result.add(obj); } - static ImmutableSet empty() { + static ImmutableSet empty() { return DefaultImmutableSet.nil(); } - static ImmutableSet fromCollection(@Nonnull Collection seq) { - return fromSet(new HashSet<>(seq)); - } - /** * @return a {@code Set} containing the same elements as this {@code ImmutableSet} */ @@ -112,7 +96,7 @@ static ImmutableSet fromCollection(@Nonnull Collection seq) * @return true iff the this set is subset of o and vice versa. */ @Override - boolean equals(Object o); + boolean equals(@Nullable Object o); @Override int hashCode(); diff --git a/key.util/src/main/java/org/key_project/util/collection/Immutables.java b/key.util/src/main/java/org/key_project/util/collection/Immutables.java index 543cfcc72d9..a88cf9acb00 100644 --- a/key.util/src/main/java/org/key_project/util/collection/Immutables.java +++ b/key.util/src/main/java/org/key_project/util/collection/Immutables.java @@ -1,13 +1,12 @@ package org.key_project.util.collection; -import org.jspecify.annotations.NullMarked; -import org.jspecify.annotations.Nullable; - import java.util.HashSet; -import java.util.Set; import java.util.function.Function; import java.util.function.Predicate; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; + /** * This class is a collection of methods that operate on immutable collections, in particular * {@link ImmutableSet}s and {@link ImmutableList}s. @@ -73,7 +72,8 @@ public static boolean isDuplicateFree(ImmutableList list) { * * @return a duplicate-free version of the argument, never null */ - public static ImmutableList removeDuplicates(ImmutableList list) { + public static ImmutableList removeDuplicates( + ImmutableList list) { if (list.isEmpty()) { return list; @@ -117,10 +117,11 @@ public static ImmutableList removeDuplicates(ImmutableList list) { } - public static ImmutableList concatDuplicateFreeLists(ImmutableList l1, + public static ImmutableList concatDuplicateFreeLists( + ImmutableList l1, ImmutableList l2) { - Set lookup = new HashSet<>(); + HashSet lookup = new HashSet<>(); for (T element : l1) { lookup.add(element); } @@ -135,7 +136,19 @@ public static ImmutableList concatDuplicateFreeLists(ImmutableList l1, return result; } - public static ImmutableSet createSetFrom(Iterable iterable) { + /** + * Returns an immutable set consisting of the elements of the + * given iterable collection. + * + * The iteration order of the result is identical to that of the argument. + * + * @param iterable the collection to iterate through to obtain the elements + * for the resulting list + * + * @return the view onto the iterable as an immutable set + */ + public static ImmutableSet createSetFrom( + Iterable iterable) { return DefaultImmutableSet.fromImmutableList(createListFrom(iterable)); } @@ -148,9 +161,9 @@ public static ImmutableSet createSetFrom(Iterable iterable) { * @param iterable the collection to iterate through to obtain the elements * for the resulting list * - * @returns the view onto the iterable as an immutable list + * @return the view onto the iterable as an immutable list */ - public static ImmutableList createListFrom(Iterable iterable) { + public static ImmutableList createListFrom(Iterable iterable) { ImmutableList result = ImmutableSLList.nil(); for (T t : iterable) { result = result.prepend(t); @@ -170,7 +183,8 @@ public static ImmutableList createListFrom(Iterable iterable) { * * @returns the filtered list */ - public static ImmutableList filter(ImmutableList ts, Predicate predicate) { + public static ImmutableList filter(ImmutableList ts, + Predicate predicate) { // This must be a loop. A tail recursive implementation is not optimised // by the compiler and quickly leads to a stack overlow. ImmutableList acc = ImmutableSLList.nil(); @@ -193,7 +207,8 @@ public static ImmutableList createListFrom(Iterable iterable) { * @param function a non-interfering, stateless function to apply to each element * @return the mapped list of the same length as this */ - public static ImmutableList map(ImmutableList ts, Function function) { + public static ImmutableList map( + ImmutableList ts, Function function) { // This must be a loop. A tail recursive implementation is not optimised // by the compiler and quickly leads to a stack overlow. ImmutableList acc = ImmutableSLList.nil(); diff --git a/key.util/src/main/java/org/key_project/util/collection/NotUniqueException.java b/key.util/src/main/java/org/key_project/util/collection/NotUniqueException.java index 360179ba951..d4bcb3755b4 100644 --- a/key.util/src/main/java/org/key_project/util/collection/NotUniqueException.java +++ b/key.util/src/main/java/org/key_project/util/collection/NotUniqueException.java @@ -1,21 +1,22 @@ package org.key_project.util.collection; +import org.jspecify.annotations.Nullable; /** thrown if a duplicate is being added via addUnique() */ @SuppressWarnings("nullness") public class NotUniqueException extends Exception { private static final long serialVersionUID = 6565515240836947955L; - final Object offender; + final @Nullable Object offender; - public NotUniqueException(Object o) { + public NotUniqueException(@Nullable Object o) { offender = o; } @Override public String toString() { - return "Tried to add a duplicate object to set. Offender is \n" + offender + "\nof class " - + offender.getClass(); + return "Tried to add a duplicate object to set. Offender is \n" + offender + + (offender != null ? " of class " + offender.getClass() : ""); } } From 6a62091b9c39754df461a18bb577b547c3e0c6d2 Mon Sep 17 00:00:00 2001 From: Alexander Weigl Date: Fri, 21 Jul 2023 01:08:46 +0200 Subject: [PATCH 18/37] JSR305 to jspecify --- build.gradle | 1 - .../rule/ModalitySideProofRule.java | 4 +- .../key/settings/TestGenerationSettings.java | 6 +-- .../ilkd/key/java/ParseExceptionInFile.java | 2 +- .../ilkd/key/java/PosConvertException.java | 2 +- .../de/uka/ilkd/key/java/PositionInfo.java | 2 +- .../de/uka/ilkd/key/java/Recoder2KeY.java | 2 +- .../key/java/recoderext/JMLTransformer.java | 4 +- .../java/de/uka/ilkd/key/ldt/CharListLDT.java | 2 +- .../java/de/uka/ilkd/key/ldt/IntegerLDT.java | 2 +- .../main/java/de/uka/ilkd/key/ldt/LDT.java | 2 +- .../java/de/uka/ilkd/key/ldt/LocSetLDT.java | 2 +- .../main/java/de/uka/ilkd/key/ldt/SeqLDT.java | 2 +- .../java/de/uka/ilkd/key/logic/Choice.java | 12 ++--- .../de/uka/ilkd/key/logic/ChoiceExpr.java | 28 +++++------ .../java/de/uka/ilkd/key/logic/Namespace.java | 2 +- .../main/java/de/uka/ilkd/key/logic/Term.java | 2 +- .../de/uka/ilkd/key/logic/TermFactory.java | 10 ++-- .../java/de/uka/ilkd/key/logic/TermImpl.java | 2 +- .../ilkd/key/logic/label/OriginTermLabel.java | 2 +- .../uka/ilkd/key/logic/sort/AbstractSort.java | 2 +- .../java/de/uka/ilkd/key/logic/sort/Sort.java | 2 +- .../ilkd/key/macros/scripts/EngineState.java | 4 +- .../key/macros/scripts/ScriptException.java | 2 +- .../key/macros/scripts/ScriptLineParser.java | 2 +- .../java/de/uka/ilkd/key/nparser/KeyAst.java | 8 +-- .../java/de/uka/ilkd/key/nparser/KeyIO.java | 12 ++--- .../uka/ilkd/key/nparser/ParsingFacade.java | 14 +++--- .../ilkd/key/nparser/ProblemInformation.java | 8 +-- .../uka/ilkd/key/nparser/ProofReplayer.java | 4 +- .../key/nparser/builder/AbstractBuilder.java | 6 +-- .../key/nparser/builder/BuilderHelpers.java | 2 +- .../key/nparser/builder/ChoiceFinder.java | 8 +-- .../builder/ContractsAndInvariantsFinder.java | 6 +-- .../nparser/builder/ExpressionBuilder.java | 2 +- .../builder/FindProblemInformation.java | 6 +-- .../key/nparser/builder/ProblemFinder.java | 2 +- .../key/nparser/builder/TacletPBuilder.java | 6 +-- .../varexp/AbstractConditionBuilder.java | 6 +-- .../varexp/AbstractTacletBuilderCommand.java | 12 ++--- .../nparser/varexp/TacletBuilderCommand.java | 4 +- .../varexp/TacletBuilderManipulators.java | 8 +-- .../java/de/uka/ilkd/key/parser/Location.java | 4 +- .../uka/ilkd/key/parser/ParserException.java | 2 +- .../main/java/de/uka/ilkd/key/proof/Goal.java | 4 +- .../main/java/de/uka/ilkd/key/proof/Node.java | 6 +-- .../java/de/uka/ilkd/key/proof/Proof.java | 8 +-- .../de/uka/ilkd/key/proof/RuleAppIndex.java | 2 +- .../SVInstantiationExceptionWithPosition.java | 2 +- .../de/uka/ilkd/key/proof/TacletAppIndex.java | 6 +-- .../de/uka/ilkd/key/proof/TacletIndex.java | 2 +- .../uka/ilkd/key/proof/init/InitConfig.java | 6 +-- .../key/proof/init/KeYUserProblemFile.java | 4 +- .../de/uka/ilkd/key/proof/io/EnvInput.java | 6 +-- .../uka/ilkd/key/proof/io/FileRuleSource.java | 6 +-- .../proof/io/IntermediateProofReplayer.java | 4 +- .../de/uka/ilkd/key/proof/io/KeYFile.java | 16 +++--- .../ilkd/key/rule/AbstractBuiltInRuleApp.java | 2 +- .../key/rule/BlockContractExternalRule.java | 4 +- .../key/rule/BlockContractInternalRule.java | 4 +- .../de/uka/ilkd/key/rule/BuiltInRule.java | 2 +- .../java/de/uka/ilkd/key/rule/HasOrigin.java | 2 +- .../de/uka/ilkd/key/rule/JmlAssertRule.java | 4 +- .../uka/ilkd/key/rule/LoopApplyHeadRule.java | 4 +- .../key/rule/LoopContractExternalRule.java | 4 +- .../key/rule/LoopContractInternalRule.java | 4 +- .../ilkd/key/rule/LoopScopeInvariantRule.java | 4 +- .../uka/ilkd/key/rule/OneStepSimplifier.java | 4 +- .../de/uka/ilkd/key/rule/QueryExpand.java | 4 +- .../main/java/de/uka/ilkd/key/rule/Rule.java | 4 +- .../java/de/uka/ilkd/key/rule/RuleApp.java | 2 +- .../java/de/uka/ilkd/key/rule/RuleKey.java | 8 +-- .../java/de/uka/ilkd/key/rule/Taclet.java | 6 +-- .../java/de/uka/ilkd/key/rule/TacletApp.java | 2 +- .../key/rule/UseDependencyContractRule.java | 4 +- .../key/rule/UseOperationContractRule.java | 4 +- .../uka/ilkd/key/rule/WhileInvariantRule.java | 4 +- .../ilkd/key/rule/merge/CloseAfterMerge.java | 4 +- .../de/uka/ilkd/key/rule/merge/MergeRule.java | 4 +- .../settings/AbstractPropertiesSettings.java | 10 ++-- .../uka/ilkd/key/settings/ChoiceSettings.java | 6 +-- .../ilkd/key/settings/SettingsConverter.java | 6 +-- .../java/de/uka/ilkd/key/smt/RuleAppSMT.java | 4 +- .../ilkd/key/smt/SMTSolverImplementation.java | 4 +- .../uka/ilkd/key/smt/SmtLib2Translator.java | 2 +- .../de/uka/ilkd/key/smt/VersionChecker.java | 2 +- .../communication/AbstractSolverSocket.java | 8 +-- .../key/smt/communication/CVC4Socket.java | 4 +- .../key/smt/communication/CVC5Socket.java | 4 +- .../ExternalProcessLauncher.java | 10 ++-- .../key/smt/communication/LegacyPipe.java | 8 +-- .../uka/ilkd/key/smt/communication/Pipe.java | 8 +-- .../key/smt/communication/SimplePipe.java | 22 ++++---- .../ilkd/key/smt/communication/TeeReader.java | 8 +-- .../ilkd/key/smt/communication/TeeWriter.java | 8 +-- .../key/smt/communication/Z3CESocket.java | 4 +- .../ilkd/key/smt/communication/Z3Socket.java | 4 +- .../ilkd/key/smt/newsmt2/MasterHandler.java | 2 +- .../smt/newsmt2/ModularSMTLib2Translator.java | 2 +- .../key/smt/newsmt2/SMTHandlerServices.java | 4 +- .../ilkd/key/smt/solvertypes/SolverType.java | 6 +-- .../solvertypes/SolverTypeImplementation.java | 6 +-- .../ilkd/key/smt/solvertypes/SolverTypes.java | 6 +-- .../ilkd/key/speclang/PositionedString.java | 14 +++--- .../key/speclang/SpecificationElement.java | 2 +- .../key/speclang/jml/JMLInfoExtractor.java | 18 +++---- .../uka/ilkd/key/speclang/jml/JMLUtils.java | 6 +-- .../pretranslation/TextualJMLConstruct.java | 4 +- .../jml/pretranslation/TextualJMLDepends.java | 4 +- .../pretranslation/TextualJMLLoopSpec.java | 2 +- .../TextualJMLMergePointDecl.java | 10 ++-- .../pretranslation/TextualJMLSpecCase.java | 15 +++--- .../key/speclang/jml/translation/Context.java | 12 ++--- .../jml/translation/JMLSpecFactory.java | 22 ++++---- .../key/speclang/njml/ContractClauses.java | 2 +- .../ilkd/key/speclang/njml/DoubleHandler.java | 2 +- .../ilkd/key/speclang/njml/FloatHandler.java | 2 +- .../key/speclang/njml/IntegerHandler.java | 2 +- .../uka/ilkd/key/speclang/njml/JmlCheck.java | 6 +-- .../uka/ilkd/key/speclang/njml/JmlChecks.java | 4 +- .../uka/ilkd/key/speclang/njml/JmlFacade.java | 14 +++--- .../de/uka/ilkd/key/speclang/njml/JmlIO.java | 16 +++--- .../key/speclang/njml/JmlMarkerDecision.java | 4 +- .../key/speclang/njml/JmlTermFactory.java | 50 +++++++++---------- .../ilkd/key/speclang/njml/LDTHandler.java | 2 +- .../njml/LabeledParserRuleContext.java | 6 +-- .../njml/OverloadedOperatorHandler.java | 2 +- .../uka/ilkd/key/speclang/njml/PreParser.java | 6 +-- .../key/speclang/njml/TextualTranslator.java | 2 +- .../ilkd/key/speclang/njml/Translator.java | 12 ++--- .../JavaIntegerSemanticsHelper.java | 6 +-- .../translation/SLExceptionFactory.java | 4 +- .../speclang/translation/SLExpression.java | 10 ++-- .../translation/SLTranslationException.java | 2 +- .../ilkd/key/strategy/NumberRuleAppCost.java | 6 +-- .../strategy/QueueRuleApplicationManager.java | 2 +- .../de/uka/ilkd/key/strategy/RuleAppCost.java | 12 ++--- .../uka/ilkd/key/strategy/TopRuleAppCost.java | 10 ++-- .../feature/AppliedRuleAppsNameCache.java | 6 +-- .../lemma/TacletProofObligationInput.java | 2 +- .../lemma/TacletSoundnessPOLoader.java | 2 +- .../de/uka/ilkd/key/util/ExceptionTools.java | 6 +-- .../java/de/uka/ilkd/key/util/MiscTools.java | 2 +- .../ilkd/key/util/RecognitionException.java | 2 +- .../key/util/mergerule/MergeRuleUtils.java | 4 +- .../key/util/parsing/BuildingException.java | 2 +- .../ilkd/key/util/parsing/BuildingIssue.java | 2 +- .../ilkd/key/util/parsing/HasLocation.java | 2 +- .../key/util/parsing/LocatableException.java | 2 +- .../key/util/parsing/SyntaxErrorReporter.java | 2 +- .../de/uka/ilkd/key/util/pp/Layouter.java | 4 +- .../ilkd/key/nparser/TestTacletEquality.java | 4 +- .../ilkd/key/parser/TestTermParserHeap.java | 4 +- .../ilkd/key/rule/merge/MergeRuleTests.java | 4 +- .../key/smt/newsmt2/MasterHandlerTest.java | 2 +- .../de/uka/ilkd/key/core/KeYMediator.java | 8 +-- .../main/java/de/uka/ilkd/key/core/Log.java | 2 +- .../key/gui/KeYFileChooserBookmarkPanel.java | 6 +-- .../ilkd/key/gui/KeyboardTacletExtension.java | 10 ++-- .../java/de/uka/ilkd/key/gui/MainWindow.java | 4 +- .../ilkd/key/gui/PositionedIssueString.java | 18 +++---- .../ilkd/key/gui/ProofManagementDialog.java | 10 ++-- .../java/de/uka/ilkd/key/gui/SearchBar.java | 4 +- .../key/gui/actions/EditSourceFileAction.java | 2 +- .../gui/actions/LemmaGenerationAction.java | 2 +- .../key/gui/actions/RunAllProofsAction.java | 6 +-- .../ilkd/key/gui/docking/DockingHelper.java | 8 +-- .../ilkd/key/gui/docking/DockingLayout.java | 6 +-- .../gui/extension/api/KeYGuiExtension.java | 22 ++++---- .../ilkd/key/gui/extension/api/TabPanel.java | 12 ++--- .../key/gui/extension/impl/TestExtension.java | 8 +-- .../gui/lemmatagenerator/LemmataHandler.java | 2 +- .../gui/nodeviews/SequentViewSearchBar.java | 4 +- .../javac/JavaCompilerCheckFacade.java | 4 +- .../gui/prooftree/GUIAbstractTreeNode.java | 4 +- .../ilkd/key/gui/prooftree/GUIBranchNode.java | 4 +- .../prooftree/GUIOneStepChildTreeNode.java | 4 +- .../key/gui/prooftree/GUIProofTreeModel.java | 8 +-- .../key/gui/prooftree/GUIProofTreeNode.java | 4 +- .../prooftree/ProofTreeExpansionState.java | 20 ++++---- .../key/gui/prooftree/ProofTreeSearchBar.java | 8 +-- .../ilkd/key/gui/prooftree/ProofTreeView.java | 8 +-- .../de/uka/ilkd/key/gui/prooftree/Style.java | 10 ++-- .../de/uka/ilkd/key/gui/prooftree/Styler.java | 4 +- .../ilkd/key/gui/settings/SettingsPanel.java | 2 +- .../key/gui/settings/SimpleSettingsPanel.java | 2 +- .../gui/settings/TacletOptionsSettings.java | 4 +- key.util/build.gradle | 22 ++++---- .../util/collection/ImmutableArray.java | 4 +- .../exploration/ExplorationExtension.java | 22 ++++---- .../exploration/ExplorationModeModel.java | 6 +-- .../exploration/ExplorationNodeData.java | 6 +-- .../exploration/ProofExplorationService.java | 28 +++++------ .../actions/AddFormulaToAntecedentAction.java | 4 +- .../actions/AddFormulaToSuccedentAction.java | 4 +- .../exploration/ui/ExplorationStepsList.java | 16 +++--- .../key_project/slicing/SlicingExtension.java | 14 +++--- .../slicing/ui/SlicingLeftPanel.java | 8 +-- .../key/gui/testgen/TestgenExtension.java | 6 +-- .../testsuite/basic/BasicTestsSuite.java | 6 +-- settings.gradle | 3 ++ 201 files changed, 623 insertions(+), 618 deletions(-) diff --git a/build.gradle b/build.gradle index c6435989897..ccd25bd3fe4 100644 --- a/build.gradle +++ b/build.gradle @@ -86,7 +86,6 @@ subprojects { //compile group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.12.0' //compile group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.12.0' - implementation 'com.google.code.findbugs:jsr305:3.0.2' compileOnly 'org.jspecify:jspecify:0.3.0' compileOnly 'io.github.eisop:checker-qual:3.34.0-eisop1' diff --git a/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/rule/ModalitySideProofRule.java b/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/rule/ModalitySideProofRule.java index bf757eac66d..007be5aa9d4 100644 --- a/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/rule/ModalitySideProofRule.java +++ b/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/rule/ModalitySideProofRule.java @@ -3,7 +3,7 @@ import java.util.LinkedHashSet; import java.util.List; import java.util.Set; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.logic.Name; @@ -130,7 +130,7 @@ public IBuiltInRuleApp createApp(PosInOccurrence pos, TermServices services) { /** * {@inheritDoc} */ - @Nonnull + @NonNull @Override public ImmutableList apply(Goal goal, Services services, RuleApp ruleApp) throws RuleAbortException { diff --git a/key.core.testgen/src/main/java/de/uka/ilkd/key/settings/TestGenerationSettings.java b/key.core.testgen/src/main/java/de/uka/ilkd/key/settings/TestGenerationSettings.java index 014ed1541b9..579162b88e8 100644 --- a/key.core.testgen/src/main/java/de/uka/ilkd/key/settings/TestGenerationSettings.java +++ b/key.core.testgen/src/main/java/de/uka/ilkd/key/settings/TestGenerationSettings.java @@ -2,8 +2,8 @@ import java.io.File; import java.util.Properties; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import org.jspecify.annotations.NonNull; +import org.jspecify.annotations.Nullable; public class TestGenerationSettings extends AbstractSettings { // region Default Values for option fields @@ -276,7 +276,7 @@ public void set(TestGenerationSettings settings) { @Nullable private static TestGenerationSettings instance; - public static @Nonnull TestGenerationSettings getInstance() { + public static @NonNull TestGenerationSettings getInstance() { if (instance == null) { instance = new TestGenerationSettings(); ProofIndependentSettings.DEFAULT_INSTANCE.addSettings(instance); diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/ParseExceptionInFile.java b/key.core/src/main/java/de/uka/ilkd/key/java/ParseExceptionInFile.java index e94c21de9c0..7f92533f8ac 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/ParseExceptionInFile.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/ParseExceptionInFile.java @@ -1,7 +1,7 @@ package de.uka.ilkd.key.java; import java.net.MalformedURLException; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.parser.Location; import de.uka.ilkd.key.util.ExceptionTools; diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/PosConvertException.java b/key.core/src/main/java/de/uka/ilkd/key/java/PosConvertException.java index 56e16c25080..7b8884ab889 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/PosConvertException.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/PosConvertException.java @@ -2,7 +2,7 @@ import java.net.MalformedURLException; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.parser.Location; import de.uka.ilkd.key.util.parsing.HasLocation; diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/PositionInfo.java b/key.core/src/main/java/de/uka/ilkd/key/java/PositionInfo.java index 0cab1e464fb..ee62634cfba 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/PositionInfo.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/PositionInfo.java @@ -5,7 +5,7 @@ import java.net.URL; import java.nio.file.Paths; import java.util.Optional; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; import recoder.java.SourceElement; diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/Recoder2KeY.java b/key.core/src/main/java/de/uka/ilkd/key/java/Recoder2KeY.java index 9eba82aa418..bb6149c4068 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/Recoder2KeY.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/Recoder2KeY.java @@ -5,7 +5,7 @@ import java.nio.charset.StandardCharsets; import java.nio.file.Paths; import java.util.*; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.java.abstraction.KeYJavaType; import de.uka.ilkd.key.java.abstraction.NullType; diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/recoderext/JMLTransformer.java b/key.core/src/main/java/de/uka/ilkd/key/java/recoderext/JMLTransformer.java index 07c8d455d87..73f0b006aa1 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/recoderext/JMLTransformer.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/recoderext/JMLTransformer.java @@ -2,7 +2,7 @@ import java.net.URI; import java.util.*; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.parser.Location; import de.uka.ilkd.key.settings.ProofIndependentSettings; @@ -731,7 +731,7 @@ private static class TypeDeclarationCollector extends SourceVisitor { final HashSet result = new LinkedHashSet<>(); - public void walk(@Nonnull SourceElement s) { + public void walk(@NonNull SourceElement s) { s.accept(this); if (s instanceof NonTerminalProgramElement) { NonTerminalProgramElement pe = (NonTerminalProgramElement) s; diff --git a/key.core/src/main/java/de/uka/ilkd/key/ldt/CharListLDT.java b/key.core/src/main/java/de/uka/ilkd/key/ldt/CharListLDT.java index 4fce9abd085..c601efe4f77 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/ldt/CharListLDT.java +++ b/key.core/src/main/java/de/uka/ilkd/key/ldt/CharListLDT.java @@ -1,6 +1,6 @@ package de.uka.ilkd.key.ldt; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.java.ConvertException; import de.uka.ilkd.key.java.Expression; diff --git a/key.core/src/main/java/de/uka/ilkd/key/ldt/IntegerLDT.java b/key.core/src/main/java/de/uka/ilkd/key/ldt/IntegerLDT.java index 86345484dd4..1e2f6de880c 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/ldt/IntegerLDT.java +++ b/key.core/src/main/java/de/uka/ilkd/key/ldt/IntegerLDT.java @@ -1,6 +1,6 @@ package de.uka.ilkd.key.ldt; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.java.Expression; import de.uka.ilkd.key.java.Services; diff --git a/key.core/src/main/java/de/uka/ilkd/key/ldt/LDT.java b/key.core/src/main/java/de/uka/ilkd/key/ldt/LDT.java index 21631a02567..9341343c9eb 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/ldt/LDT.java +++ b/key.core/src/main/java/de/uka/ilkd/key/ldt/LDT.java @@ -2,7 +2,7 @@ import java.util.Map; import java.util.TreeMap; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.java.Expression; import de.uka.ilkd.key.java.Services; diff --git a/key.core/src/main/java/de/uka/ilkd/key/ldt/LocSetLDT.java b/key.core/src/main/java/de/uka/ilkd/key/ldt/LocSetLDT.java index 55d9e5dc57c..52164d24769 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/ldt/LocSetLDT.java +++ b/key.core/src/main/java/de/uka/ilkd/key/ldt/LocSetLDT.java @@ -1,6 +1,6 @@ package de.uka.ilkd.key.ldt; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.java.Expression; import de.uka.ilkd.key.java.Services; diff --git a/key.core/src/main/java/de/uka/ilkd/key/ldt/SeqLDT.java b/key.core/src/main/java/de/uka/ilkd/key/ldt/SeqLDT.java index 98f8f859d8b..3a9cc27e638 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/ldt/SeqLDT.java +++ b/key.core/src/main/java/de/uka/ilkd/key/ldt/SeqLDT.java @@ -1,6 +1,6 @@ package de.uka.ilkd.key.ldt; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.java.Expression; import de.uka.ilkd.key.java.Services; diff --git a/key.core/src/main/java/de/uka/ilkd/key/logic/Choice.java b/key.core/src/main/java/de/uka/ilkd/key/logic/Choice.java index 468815c447a..1578f464b22 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/logic/Choice.java +++ b/key.core/src/main/java/de/uka/ilkd/key/logic/Choice.java @@ -3,7 +3,7 @@ import java.util.List; import java.util.Objects; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; /** * A choice is an option in a category. @@ -15,8 +15,8 @@ * @see de.uka.ilkd.key.nparser.ParsingFacade#getChoices(List) */ public class Choice implements Named { - private final @Nonnull Name name; - private final @Nonnull String category; + private final @NonNull Name name; + private final @NonNull String category; /** * Creates a choice object with name <category>:<choice>. @@ -25,18 +25,18 @@ public Choice(String choice, String category) { this(new Name(category + ":" + choice), category); } - public Choice(@Nonnull Name name, @Nonnull String category) { + public Choice(@NonNull Name name, @NonNull String category) { this.name = name; this.category = category; } @Override - public @Nonnull Name name() { + public @NonNull Name name() { return name; } - public @Nonnull String category() { + public @NonNull String category() { return category; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/logic/ChoiceExpr.java b/key.core/src/main/java/de/uka/ilkd/key/logic/ChoiceExpr.java index ddcf1ef180b..5344e9c2ea8 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/logic/ChoiceExpr.java +++ b/key.core/src/main/java/de/uka/ilkd/key/logic/ChoiceExpr.java @@ -2,7 +2,7 @@ import java.util.Objects; import java.util.Set; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; /** * A ChoiceExpr is a boolean expression that determines whether a taclet or a goal should be @@ -43,14 +43,14 @@ public static ChoiceExpr not(ChoiceExpr sub) { * @param current activated choices * @return true if the expr is true given the assignment in {@code current} */ - public abstract boolean eval(@Nonnull Set current); + public abstract boolean eval(@NonNull Set current); @Override public abstract String toString(); private static class True extends ChoiceExpr { @Override - public boolean eval(@Nonnull Set current) { + public boolean eval(@NonNull Set current) { return true; } @@ -63,14 +63,14 @@ public String toString() { private static class Proposition extends ChoiceExpr { - public final @Nonnull Choice choice; + public final @NonNull Choice choice; public Proposition(String category, String option) { this.choice = new Choice(option, category); } @Override - public boolean eval(@Nonnull Set current) { + public boolean eval(@NonNull Set current) { return current.contains(choice); } @@ -98,16 +98,16 @@ public int hashCode() { } private static class And extends ChoiceExpr { - public final @Nonnull ChoiceExpr left; - public final @Nonnull ChoiceExpr right; + public final @NonNull ChoiceExpr left; + public final @NonNull ChoiceExpr right; - public And(@Nonnull ChoiceExpr left, @Nonnull ChoiceExpr right) { + public And(@NonNull ChoiceExpr left, @NonNull ChoiceExpr right) { this.left = left; this.right = right; } @Override - public boolean eval(@Nonnull Set current) { + public boolean eval(@NonNull Set current) { return left.eval(current) && right.eval(current); } @@ -135,16 +135,16 @@ public int hashCode() { } private static class Or extends ChoiceExpr { - public final @Nonnull ChoiceExpr left; - public final @Nonnull ChoiceExpr right; + public final @NonNull ChoiceExpr left; + public final @NonNull ChoiceExpr right; - public Or(@Nonnull ChoiceExpr left, @Nonnull ChoiceExpr right) { + public Or(@NonNull ChoiceExpr left, @NonNull ChoiceExpr right) { this.left = left; this.right = right; } @Override - public boolean eval(@Nonnull Set current) { + public boolean eval(@NonNull Set current) { return left.eval(current) || right.eval(current); } @@ -179,7 +179,7 @@ public Not(ChoiceExpr sub) { } @Override - public boolean eval(@Nonnull Set current) { + public boolean eval(@NonNull Set current) { return !sub.eval(current); } diff --git a/key.core/src/main/java/de/uka/ilkd/key/logic/Namespace.java b/key.core/src/main/java/de/uka/ilkd/key/logic/Namespace.java index bf03d3a592a..08787ef0d29 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/logic/Namespace.java +++ b/key.core/src/main/java/de/uka/ilkd/key/logic/Namespace.java @@ -5,7 +5,7 @@ import java.util.Collections; import java.util.LinkedHashMap; import java.util.Map; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; import org.key_project.util.collection.ImmutableSet; diff --git a/key.core/src/main/java/de/uka/ilkd/key/logic/Term.java b/key.core/src/main/java/de/uka/ilkd/key/logic/Term.java index 547156e0a22..c332353c7b9 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/logic/Term.java +++ b/key.core/src/main/java/de/uka/ilkd/key/logic/Term.java @@ -1,6 +1,6 @@ package de.uka.ilkd.key.logic; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.logic.label.TermLabel; import de.uka.ilkd.key.logic.op.Operator; diff --git a/key.core/src/main/java/de/uka/ilkd/key/logic/TermFactory.java b/key.core/src/main/java/de/uka/ilkd/key/logic/TermFactory.java index 69f84f01225..72dffba9403 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/logic/TermFactory.java +++ b/key.core/src/main/java/de/uka/ilkd/key/logic/TermFactory.java @@ -3,7 +3,7 @@ import java.util.List; import java.util.Map; import java.util.Optional; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.logic.label.TermLabel; import de.uka.ilkd.key.logic.op.Operator; @@ -50,7 +50,7 @@ public TermFactory(Map cache) { * Master method for term creation. Should be the only place where terms are created in the * entire system. */ - public Term createTerm(@Nonnull Operator op, ImmutableArray subs, + public Term createTerm(@NonNull Operator op, ImmutableArray subs, ImmutableArray boundVars, JavaBlock javaBlock, ImmutableArray labels) { if (op == null) { @@ -71,13 +71,13 @@ public Term createTerm(Operator op, ImmutableArray subs, } - public Term createTerm(@Nonnull Operator op, Term[] subs, + public Term createTerm(@NonNull Operator op, Term[] subs, ImmutableArray boundVars, JavaBlock javaBlock) { return createTerm(op, createSubtermArray(subs), boundVars, javaBlock, null); } - public Term createTerm(@Nonnull Operator op, Term... subs) { + public Term createTerm(@NonNull Operator op, Term... subs) { return createTerm(op, subs, null, null); } @@ -154,7 +154,7 @@ private Term doCreateTerm(Operator op, ImmutableArray subs, * @param junctor the left-associative operator to combine the terms together * @param terms a list of non-null temrs */ - public @Nonnull Term createTerm(@Nonnull Operator junctor, @Nonnull List terms) { + public @NonNull Term createTerm(@NonNull Operator junctor, @NonNull List terms) { if (terms.size() == 1) { return terms.get(0); } else if (terms.size() == 2) { diff --git a/key.core/src/main/java/de/uka/ilkd/key/logic/TermImpl.java b/key.core/src/main/java/de/uka/ilkd/key/logic/TermImpl.java index 12c2ff722fb..b87f2d0a79c 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/logic/TermImpl.java +++ b/key.core/src/main/java/de/uka/ilkd/key/logic/TermImpl.java @@ -2,7 +2,7 @@ import java.util.Objects; import java.util.concurrent.atomic.AtomicInteger; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.java.NameAbstractionTable; import de.uka.ilkd.key.java.PositionInfo; diff --git a/key.core/src/main/java/de/uka/ilkd/key/logic/label/OriginTermLabel.java b/key.core/src/main/java/de/uka/ilkd/key/logic/label/OriginTermLabel.java index 85ff9684615..0873843f517 100755 --- a/key.core/src/main/java/de/uka/ilkd/key/logic/label/OriginTermLabel.java +++ b/key.core/src/main/java/de/uka/ilkd/key/logic/label/OriginTermLabel.java @@ -2,7 +2,7 @@ import java.net.URI; import java.util.*; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.java.JavaInfo; import de.uka.ilkd.key.java.Services; diff --git a/key.core/src/main/java/de/uka/ilkd/key/logic/sort/AbstractSort.java b/key.core/src/main/java/de/uka/ilkd/key/logic/sort/AbstractSort.java index 0f415b4c8f5..a541077ab1a 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/logic/sort/AbstractSort.java +++ b/key.core/src/main/java/de/uka/ilkd/key/logic/sort/AbstractSort.java @@ -1,6 +1,6 @@ package de.uka.ilkd.key.logic.sort; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.logic.Name; diff --git a/key.core/src/main/java/de/uka/ilkd/key/logic/sort/Sort.java b/key.core/src/main/java/de/uka/ilkd/key/logic/sort/Sort.java index 92f9f171934..93fb5681ff9 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/logic/sort/Sort.java +++ b/key.core/src/main/java/de/uka/ilkd/key/logic/sort/Sort.java @@ -1,6 +1,6 @@ package de.uka.ilkd.key.logic.sort; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.logic.Name; diff --git a/key.core/src/main/java/de/uka/ilkd/key/macros/scripts/EngineState.java b/key.core/src/main/java/de/uka/ilkd/key/macros/scripts/EngineState.java index e24eeb4028f..67eea4cd92a 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/macros/scripts/EngineState.java +++ b/key.core/src/main/java/de/uka/ilkd/key/macros/scripts/EngineState.java @@ -6,7 +6,7 @@ import java.util.LinkedList; import java.util.Optional; import java.util.function.Consumer; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.logic.Sequent; @@ -88,7 +88,7 @@ public Proof getProof() { * @throws ScriptException If there is no such {@link Goal}, or something else goes wrong. */ @SuppressWarnings("unused") - public @Nonnull Goal getFirstOpenGoal(boolean checkAutomatic) throws ScriptException { + public @NonNull Goal getFirstOpenGoal(boolean checkAutomatic) throws ScriptException { if (proof.closed()) { throw new ProofAlreadyClosedException("The proof is closed already"); } diff --git a/key.core/src/main/java/de/uka/ilkd/key/macros/scripts/ScriptException.java b/key.core/src/main/java/de/uka/ilkd/key/macros/scripts/ScriptException.java index 05b76f7e3cf..6bdaff1bba7 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/macros/scripts/ScriptException.java +++ b/key.core/src/main/java/de/uka/ilkd/key/macros/scripts/ScriptException.java @@ -1,6 +1,6 @@ package de.uka.ilkd.key.macros.scripts; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.parser.Location; import de.uka.ilkd.key.util.parsing.HasLocation; diff --git a/key.core/src/main/java/de/uka/ilkd/key/macros/scripts/ScriptLineParser.java b/key.core/src/main/java/de/uka/ilkd/key/macros/scripts/ScriptLineParser.java index 2129fb636cd..b9c44b06cc5 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/macros/scripts/ScriptLineParser.java +++ b/key.core/src/main/java/de/uka/ilkd/key/macros/scripts/ScriptLineParser.java @@ -5,7 +5,7 @@ import java.net.URI; import java.util.HashMap; import java.util.Map; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.java.Position; import de.uka.ilkd.key.parser.Location; diff --git a/key.core/src/main/java/de/uka/ilkd/key/nparser/KeyAst.java b/key.core/src/main/java/de/uka/ilkd/key/nparser/KeyAst.java index 74d8888753d..fd3c801436b 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/nparser/KeyAst.java +++ b/key.core/src/main/java/de/uka/ilkd/key/nparser/KeyAst.java @@ -1,8 +1,8 @@ package de.uka.ilkd.key.nparser; import java.net.URL; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import org.jspecify.annotations.NonNull; +import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.nparser.builder.BuilderHelpers; import de.uka.ilkd.key.nparser.builder.ChoiceFinder; @@ -32,10 +32,10 @@ * @version 1 (5.12.19) */ public abstract class KeyAst { - @Nonnull + @NonNull final T ctx; - protected KeyAst(@Nonnull T ctx) { + protected KeyAst(@NonNull T ctx) { this.ctx = ctx; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/nparser/KeyIO.java b/key.core/src/main/java/de/uka/ilkd/key/nparser/KeyIO.java index 829ec5fe791..8fff5d98320 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/nparser/KeyIO.java +++ b/key.core/src/main/java/de/uka/ilkd/key/nparser/KeyIO.java @@ -8,8 +8,8 @@ import java.util.LinkedList; import java.util.List; import java.util.stream.Collectors; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import org.jspecify.annotations.NonNull; +import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.logic.Namespace; @@ -54,7 +54,7 @@ public class KeyIO { private AbbrevMap abbrevMap; - public KeyIO(@Nonnull Services services, @Nonnull NamespaceSet nss) { + public KeyIO(@NonNull Services services, @NonNull NamespaceSet nss) { this.services = services; this.nss = nss; } @@ -75,7 +75,7 @@ public KeyIO() { * @return a valid term * @throws BuildingException if an unrecoverable error during construction or parsing happened */ - public @Nonnull Term parseExpression(@Nonnull String expr) { + public @NonNull Term parseExpression(@NonNull String expr) { return parseExpression(CharStreams.fromString(expr)); } @@ -86,7 +86,7 @@ public KeyIO() { * @return a valid term * @throws BuildingException if an unrecoverable error during construction or parsing happened */ - public @Nonnull Term parseExpression(@Nonnull CharStream stream) { + public @NonNull Term parseExpression(@NonNull CharStream stream) { KeyAst.Term ctx = ParsingFacade.parseExpression(stream); ExpressionBuilder visitor = new ExpressionBuilder(services, nss); visitor.setAbbrevMap(abbrevMap); @@ -106,7 +106,7 @@ public KeyIO() { * @return a valid sequent * @throws BuildingException if an unrecoverable error during construction or parsing happened */ - public @Nonnull Sequent parseSequent(@Nonnull CharStream stream) { + public @NonNull Sequent parseSequent(@NonNull CharStream stream) { KeyAst.Seq ctx = ParsingFacade.parseSequent(stream); ExpressionBuilder visitor = new ExpressionBuilder(services, nss); visitor.setAbbrevMap(abbrevMap); diff --git a/key.core/src/main/java/de/uka/ilkd/key/nparser/ParsingFacade.java b/key.core/src/main/java/de/uka/ilkd/key/nparser/ParsingFacade.java index 12d233e3bdc..a079ee69e62 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/nparser/ParsingFacade.java +++ b/key.core/src/main/java/de/uka/ilkd/key/nparser/ParsingFacade.java @@ -10,8 +10,8 @@ import java.nio.charset.CodingErrorAction; import java.nio.file.Path; import java.util.*; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import org.jspecify.annotations.NonNull; +import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.nparser.builder.ChoiceFinder; import de.uka.ilkd.key.proof.io.RuleSource; @@ -47,8 +47,8 @@ private ParsingFacade() { * @param parse tree type * @return the {@link ParserRuleContext} inside the given ast object. */ - @Nonnull - public static T getParseRuleContext(@Nonnull KeyAst ast) { + @NonNull + public static T getParseRuleContext(@NonNull KeyAst ast) { return ast.ctx; } @@ -78,7 +78,7 @@ public static List parseFiles(URL url) throws IOException { * * @param ctxs non-null list */ - public static @Nonnull ChoiceInformation getChoices(@Nonnull List ctxs) { + public static @NonNull ChoiceInformation getChoices(@NonNull List ctxs) { ChoiceInformation ci = new ChoiceInformation(); ChoiceFinder finder = new ChoiceFinder(ci); ctxs.forEach(it -> it.accept(finder)); @@ -162,8 +162,8 @@ public static KeyAst.Seq parseSequent(CharStream stream) { * @param ctx non-null context * @return non-null string */ - public static @Nonnull String getValueDocumentation( - @Nonnull KeYParser.String_valueContext ctx) { + public static @NonNull String getValueDocumentation( + @NonNull KeYParser.String_valueContext ctx) { return ctx.getText().substring(1, ctx.getText().length() - 1).replace("\\\"", "\"") .replace("\\\\", "\\"); } diff --git a/key.core/src/main/java/de/uka/ilkd/key/nparser/ProblemInformation.java b/key.core/src/main/java/de/uka/ilkd/key/nparser/ProblemInformation.java index 7fe9fd150f3..eb65b17d06f 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/nparser/ProblemInformation.java +++ b/key.core/src/main/java/de/uka/ilkd/key/nparser/ProblemInformation.java @@ -2,8 +2,8 @@ import java.util.LinkedList; import java.util.List; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import org.jspecify.annotations.NonNull; +import org.jspecify.annotations.Nullable; /** * This POJO represents the static information of a KeY problem. It can be extracted directly via @@ -21,7 +21,7 @@ public class ProblemInformation { /** * A list of class paths entries. */ - private final @Nonnull List classpath; + private final @NonNull List classpath; /** * Value of a "\chooseContract". If "\chooseContract" are mentioned in the file, but without a @@ -119,7 +119,7 @@ public void setJavaSource(@Nullable String javaSource) { this.javaSource = javaSource; } - @Nonnull + @NonNull public List getClasspath() { return classpath; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/nparser/ProofReplayer.java b/key.core/src/main/java/de/uka/ilkd/key/nparser/ProofReplayer.java index 505028f19f4..18da383eb74 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/nparser/ProofReplayer.java +++ b/key.core/src/main/java/de/uka/ilkd/key/nparser/ProofReplayer.java @@ -3,7 +3,7 @@ import java.net.URI; import java.net.URL; import java.util.*; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.java.Position; import de.uka.ilkd.key.parser.Location; @@ -50,7 +50,7 @@ private ProofReplayer() { * @param source the source of the stream, used for producing exceptions with locations * @see #run(CharStream, IProofFileParser, int, URI) */ - public static void run(@Nonnull Token token, CharStream input, IProofFileParser prl, + public static void run(@NonNull Token token, CharStream input, IProofFileParser prl, URI source) { input.seek(1 + token.getStopIndex()); // ends now on \proof| run(input, prl, token.getLine(), source); diff --git a/key.core/src/main/java/de/uka/ilkd/key/nparser/builder/AbstractBuilder.java b/key.core/src/main/java/de/uka/ilkd/key/nparser/builder/AbstractBuilder.java index a720032c77a..9c63b545c4b 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/nparser/builder/AbstractBuilder.java +++ b/key.core/src/main/java/de/uka/ilkd/key/nparser/builder/AbstractBuilder.java @@ -2,8 +2,8 @@ import java.util.*; import java.util.stream.Collectors; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import org.jspecify.annotations.NonNull; +import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.nparser.KeYParserBaseVisitor; import de.uka.ilkd.key.util.parsing.BuildingException; @@ -137,7 +137,7 @@ protected List mapMapOf(List... ctxss) { .collect(Collectors.toList()); } - public @Nonnull List getBuildingIssues() { + public @NonNull List getBuildingIssues() { if (buildingIssues == null) { buildingIssues = new LinkedList<>(); } diff --git a/key.core/src/main/java/de/uka/ilkd/key/nparser/builder/BuilderHelpers.java b/key.core/src/main/java/de/uka/ilkd/key/nparser/builder/BuilderHelpers.java index 4a99643bb4e..be0596fd95c 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/nparser/builder/BuilderHelpers.java +++ b/key.core/src/main/java/de/uka/ilkd/key/nparser/builder/BuilderHelpers.java @@ -1,6 +1,6 @@ package de.uka.ilkd.key.nparser.builder; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; import org.antlr.v4.runtime.ParserRuleContext; import org.antlr.v4.runtime.Token; diff --git a/key.core/src/main/java/de/uka/ilkd/key/nparser/builder/ChoiceFinder.java b/key.core/src/main/java/de/uka/ilkd/key/nparser/builder/ChoiceFinder.java index 55589a11a34..0aa5e3a48b1 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/nparser/builder/ChoiceFinder.java +++ b/key.core/src/main/java/de/uka/ilkd/key/nparser/builder/ChoiceFinder.java @@ -1,7 +1,7 @@ package de.uka.ilkd.key.nparser.builder; import java.util.*; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.logic.Choice; import de.uka.ilkd.key.logic.Name; @@ -18,14 +18,14 @@ * @see ChoiceInformation */ public class ChoiceFinder extends AbstractBuilder { - @Nonnull + @NonNull private final ChoiceInformation choiceInformation; public ChoiceFinder() { choiceInformation = new ChoiceInformation(); } - public ChoiceFinder(@Nonnull ChoiceInformation choiceInformation) { + public ChoiceFinder(@NonNull ChoiceInformation choiceInformation) { this.choiceInformation = choiceInformation; } @@ -77,7 +77,7 @@ public Choice visitActivated_choice(KeYParser.Activated_choiceContext ctx) { return c; } - @Nonnull + @NonNull public ChoiceInformation getChoiceInformation() { return choiceInformation; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/nparser/builder/ContractsAndInvariantsFinder.java b/key.core/src/main/java/de/uka/ilkd/key/nparser/builder/ContractsAndInvariantsFinder.java index e7dabdc74b1..2c435fedb23 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/nparser/builder/ContractsAndInvariantsFinder.java +++ b/key.core/src/main/java/de/uka/ilkd/key/nparser/builder/ContractsAndInvariantsFinder.java @@ -2,7 +2,7 @@ import java.util.ArrayList; import java.util.List; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.logic.Namespace; @@ -38,11 +38,11 @@ public ContractsAndInvariantsFinder(Services services, NamespaceSet nss) { declarationBuilder = new DeclarationBuilder(services, nss); } - public @Nonnull List getContracts() { + public @NonNull List getContracts() { return contracts; } - public @Nonnull List getInvariants() { + public @NonNull List getInvariants() { return invariants; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/nparser/builder/ExpressionBuilder.java b/key.core/src/main/java/de/uka/ilkd/key/nparser/builder/ExpressionBuilder.java index 4cf4a8d0654..e35c1307f28 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/nparser/builder/ExpressionBuilder.java +++ b/key.core/src/main/java/de/uka/ilkd/key/nparser/builder/ExpressionBuilder.java @@ -7,7 +7,7 @@ import java.util.Objects; import java.util.function.Supplier; import java.util.stream.Collectors; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.java.*; import de.uka.ilkd.key.java.abstraction.KeYJavaType; diff --git a/key.core/src/main/java/de/uka/ilkd/key/nparser/builder/FindProblemInformation.java b/key.core/src/main/java/de/uka/ilkd/key/nparser/builder/FindProblemInformation.java index 5061d41850b..ae9645c9248 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/nparser/builder/FindProblemInformation.java +++ b/key.core/src/main/java/de/uka/ilkd/key/nparser/builder/FindProblemInformation.java @@ -2,7 +2,7 @@ import java.util.List; import java.util.Objects; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.nparser.KeYParser; import de.uka.ilkd.key.nparser.ParsingFacade; @@ -17,7 +17,7 @@ * @see #getProblemInformation() */ public class FindProblemInformation extends AbstractBuilder { - private final @Nonnull ProblemInformation information = new ProblemInformation(); + private final @NonNull ProblemInformation information = new ProblemInformation(); @Override public Object visitFile(KeYParser.FileContext ctx) { @@ -100,7 +100,7 @@ public String visitPreferences(KeYParser.PreferencesContext ctx) { /** * The found problem information. */ - public @Nonnull ProblemInformation getProblemInformation() { + public @NonNull ProblemInformation getProblemInformation() { return information; } } diff --git a/key.core/src/main/java/de/uka/ilkd/key/nparser/builder/ProblemFinder.java b/key.core/src/main/java/de/uka/ilkd/key/nparser/builder/ProblemFinder.java index 6c5f284489e..7051d5b1c45 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/nparser/builder/ProblemFinder.java +++ b/key.core/src/main/java/de/uka/ilkd/key/nparser/builder/ProblemFinder.java @@ -1,6 +1,6 @@ package de.uka.ilkd.key.nparser.builder; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.java.abstraction.KeYJavaType; diff --git a/key.core/src/main/java/de/uka/ilkd/key/nparser/builder/TacletPBuilder.java b/key.core/src/main/java/de/uka/ilkd/key/nparser/builder/TacletPBuilder.java index 8ea9a62fb81..823f0332c91 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/nparser/builder/TacletPBuilder.java +++ b/key.core/src/main/java/de/uka/ilkd/key/nparser/builder/TacletPBuilder.java @@ -2,8 +2,8 @@ import java.util.*; import java.util.stream.Collectors; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import org.jspecify.annotations.NonNull; +import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.java.abstraction.KeYJavaType; @@ -492,7 +492,7 @@ public ImmutableList visitTacletlist(KeYParser.TacletlistContext ctx) { return ImmutableList.fromList(taclets); } - @Nonnull + @NonNull private TacletBuilder createTacletBuilderFor(Object find, int applicationRestriction, ParserRuleContext ctx) { if (find == null) { diff --git a/key.core/src/main/java/de/uka/ilkd/key/nparser/varexp/AbstractConditionBuilder.java b/key.core/src/main/java/de/uka/ilkd/key/nparser/varexp/AbstractConditionBuilder.java index 8bc6348b4b5..0456dbaa9f8 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/nparser/varexp/AbstractConditionBuilder.java +++ b/key.core/src/main/java/de/uka/ilkd/key/nparser/varexp/AbstractConditionBuilder.java @@ -1,6 +1,6 @@ package de.uka.ilkd.key.nparser.varexp; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; /** * @author Alexander Weigl @@ -8,8 +8,8 @@ */ public abstract class AbstractConditionBuilder extends AbstractTacletBuilderCommand implements ConditionBuilder { - public AbstractConditionBuilder(@Nonnull String triggerName, - @Nonnull ArgumentType... argumentsTypes) { + public AbstractConditionBuilder(@NonNull String triggerName, + @NonNull ArgumentType... argumentsTypes) { super(triggerName, argumentsTypes); } } diff --git a/key.core/src/main/java/de/uka/ilkd/key/nparser/varexp/AbstractTacletBuilderCommand.java b/key.core/src/main/java/de/uka/ilkd/key/nparser/varexp/AbstractTacletBuilderCommand.java index e997779fdd1..8690c5163f8 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/nparser/varexp/AbstractTacletBuilderCommand.java +++ b/key.core/src/main/java/de/uka/ilkd/key/nparser/varexp/AbstractTacletBuilderCommand.java @@ -1,6 +1,6 @@ package de.uka.ilkd.key.nparser.varexp; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; /** * Simple default implementation for {@link TacletBuilderCommand}. @@ -9,8 +9,8 @@ * @version 1 (12/9/19) */ public abstract class AbstractTacletBuilderCommand implements TacletBuilderCommand { - private final @Nonnull String triggerName; - private final @Nonnull ArgumentType[] argumentsTypes; + private final @NonNull String triggerName; + private final @NonNull ArgumentType[] argumentsTypes; /** * Construct this class with the parameters for {@link #isSuitableFor(String)} and @@ -19,14 +19,14 @@ public abstract class AbstractTacletBuilderCommand implements TacletBuilderComma * @param triggerName the name of this command. * @param argumentsTypes the argument type of this command. */ - public AbstractTacletBuilderCommand(@Nonnull String triggerName, - @Nonnull ArgumentType... argumentsTypes) { + public AbstractTacletBuilderCommand(@NonNull String triggerName, + @NonNull ArgumentType... argumentsTypes) { this.triggerName = triggerName; this.argumentsTypes = argumentsTypes; } @Override - public boolean isSuitableFor(@Nonnull String name) { + public boolean isSuitableFor(@NonNull String name) { if (triggerName.equalsIgnoreCase(name)) { return true; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/nparser/varexp/TacletBuilderCommand.java b/key.core/src/main/java/de/uka/ilkd/key/nparser/varexp/TacletBuilderCommand.java index f40ebb49ca6..75cc5364b63 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/nparser/varexp/TacletBuilderCommand.java +++ b/key.core/src/main/java/de/uka/ilkd/key/nparser/varexp/TacletBuilderCommand.java @@ -1,7 +1,7 @@ package de.uka.ilkd.key.nparser.varexp; import java.util.List; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.rule.tacletbuilder.TacletBuilder; @@ -20,7 +20,7 @@ public interface TacletBuilderCommand { * Checks if this command is responsible for the given command name. For example, for * {@code \varcond(\newType(t))} the name would be "newType". */ - boolean isSuitableFor(@Nonnull String name); + boolean isSuitableFor(@NonNull String name); /** * Defines the amount and type of expected arguments. For example, if you want describe a diff --git a/key.core/src/main/java/de/uka/ilkd/key/nparser/varexp/TacletBuilderManipulators.java b/key.core/src/main/java/de/uka/ilkd/key/nparser/varexp/TacletBuilderManipulators.java index 146c269dd8e..2cd6687a2b5 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/nparser/varexp/TacletBuilderManipulators.java +++ b/key.core/src/main/java/de/uka/ilkd/key/nparser/varexp/TacletBuilderManipulators.java @@ -5,7 +5,7 @@ import java.util.List; import java.util.ServiceLoader; import java.util.stream.Collectors; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.java.abstraction.KeYJavaType; import de.uka.ilkd.key.logic.Term; @@ -84,7 +84,7 @@ public TypeComparisonCondition build(Object[] arguments, List parameters public static final AbstractConditionBuilder STRICT = new AbstractConditionBuilder("scrictSub", TR, TR) { @Override - public boolean isSuitableFor(@Nonnull String name) { + public boolean isSuitableFor(@NonNull String name) { if (super.isSuitableFor(name)) { return true; } @@ -157,7 +157,7 @@ public void apply(TacletBuilder tacletBuilder, Object[] arguments, static class NotFreeInTacletBuilderCommand extends AbstractTacletBuilderCommand { - public NotFreeInTacletBuilderCommand(@Nonnull ArgumentType... argumentsTypes) { + public NotFreeInTacletBuilderCommand(@NonNull ArgumentType... argumentsTypes) { super("notFreeIn", argumentsTypes); } @@ -289,7 +289,7 @@ public VariableCondition build(Object[] arguments, List parameters, static class JavaTypeToSortConditionBuilder extends AbstractConditionBuilder { private final boolean elmen; - public JavaTypeToSortConditionBuilder(@Nonnull String triggerName, boolean forceElmentary) { + public JavaTypeToSortConditionBuilder(@NonNull String triggerName, boolean forceElmentary) { super(triggerName, SV, SORT); this.elmen = forceElmentary; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/parser/Location.java b/key.core/src/main/java/de/uka/ilkd/key/parser/Location.java index 1c83691c5b0..9772eba33f7 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/parser/Location.java +++ b/key.core/src/main/java/de/uka/ilkd/key/parser/Location.java @@ -6,7 +6,7 @@ import java.util.Comparator; import java.util.Objects; import java.util.Optional; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.java.Position; import de.uka.ilkd.key.util.MiscTools; @@ -107,7 +107,7 @@ public int hashCode() { } @Override - public int compareTo(@Nonnull Location o) { + public int compareTo(@NonNull Location o) { return Comparator .comparing(l -> l.fileUri) .thenComparing(Location::getPosition).compare(this, o); diff --git a/key.core/src/main/java/de/uka/ilkd/key/parser/ParserException.java b/key.core/src/main/java/de/uka/ilkd/key/parser/ParserException.java index b9fd0aab8d0..38249bfc482 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/parser/ParserException.java +++ b/key.core/src/main/java/de/uka/ilkd/key/parser/ParserException.java @@ -1,7 +1,7 @@ package de.uka.ilkd.key.parser; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.util.parsing.HasLocation; diff --git a/key.core/src/main/java/de/uka/ilkd/key/proof/Goal.java b/key.core/src/main/java/de/uka/ilkd/key/proof/Goal.java index c56a09a6108..81fc7f5736c 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/proof/Goal.java +++ b/key.core/src/main/java/de/uka/ilkd/key/proof/Goal.java @@ -5,7 +5,7 @@ import java.util.LinkedList; import java.util.List; import java.util.concurrent.atomic.AtomicLong; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.logic.*; @@ -536,7 +536,7 @@ public void removeLastAppliedRuleApp() { * * @return the list of new created goals. */ - @Nonnull + @NonNull public ImmutableList split(int n) { ImmutableList goalList = ImmutableSLList.nil(); diff --git a/key.core/src/main/java/de/uka/ilkd/key/proof/Node.java b/key.core/src/main/java/de/uka/ilkd/key/proof/Node.java index 4a2e1035d7d..038fd2ed8b9 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/proof/Node.java +++ b/key.core/src/main/java/de/uka/ilkd/key/proof/Node.java @@ -9,8 +9,8 @@ import java.util.LinkedList; import java.util.List; import java.util.ListIterator; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import org.jspecify.annotations.NonNull; +import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.logic.RenamingTable; import de.uka.ilkd.key.logic.Sequent; @@ -797,7 +797,7 @@ public void deregister(T obj, Class service) { * * @return */ - public @Nonnull Lookup getUserData() { + public @NonNull Lookup getUserData() { if (userData == null) { userData = new Lookup(); } diff --git a/key.core/src/main/java/de/uka/ilkd/key/proof/Proof.java b/key.core/src/main/java/de/uka/ilkd/key/proof/Proof.java index 73ccc8f68ec..8d21a46fa29 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/proof/Proof.java +++ b/key.core/src/main/java/de/uka/ilkd/key/proof/Proof.java @@ -5,8 +5,8 @@ import java.io.IOException; import java.util.*; import java.util.function.Predicate; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import org.jspecify.annotations.NonNull; +import org.jspecify.annotations.Nullable; import javax.swing.*; import de.uka.ilkd.key.java.JavaInfo; @@ -883,7 +883,7 @@ public void breadthFirstSearch(Node startNode, ProofVisitor visitor) { * @param pred non-null test function * @return a node fulfilling {@code pred} or null */ - public @Nullable Node findAny(@Nonnull Predicate pred) { + public @Nullable Node findAny(@NonNull Predicate pred) { Queue queue = new LinkedList<>(); queue.add(root); while (!queue.isEmpty()) { @@ -1411,7 +1411,7 @@ public void deregister(T obj, Class service) { * * @return the associated lookup */ - public @Nonnull Lookup getUserData() { + public @NonNull Lookup getUserData() { if (userData == null) { userData = new Lookup(); } diff --git a/key.core/src/main/java/de/uka/ilkd/key/proof/RuleAppIndex.java b/key.core/src/main/java/de/uka/ilkd/key/proof/RuleAppIndex.java index 5464486bb41..6ddc38d0a54 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/proof/RuleAppIndex.java +++ b/key.core/src/main/java/de/uka/ilkd/key/proof/RuleAppIndex.java @@ -1,6 +1,6 @@ package de.uka.ilkd.key.proof; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.logic.PosInOccurrence; diff --git a/key.core/src/main/java/de/uka/ilkd/key/proof/SVInstantiationExceptionWithPosition.java b/key.core/src/main/java/de/uka/ilkd/key/proof/SVInstantiationExceptionWithPosition.java index ffe21234780..67c796e6a1a 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/proof/SVInstantiationExceptionWithPosition.java +++ b/key.core/src/main/java/de/uka/ilkd/key/proof/SVInstantiationExceptionWithPosition.java @@ -2,7 +2,7 @@ import java.net.MalformedURLException; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.java.Position; import de.uka.ilkd.key.parser.Location; diff --git a/key.core/src/main/java/de/uka/ilkd/key/proof/TacletAppIndex.java b/key.core/src/main/java/de/uka/ilkd/key/proof/TacletAppIndex.java index 6dcb5bdab37..9126bec118f 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/proof/TacletAppIndex.java +++ b/key.core/src/main/java/de/uka/ilkd/key/proof/TacletAppIndex.java @@ -3,8 +3,8 @@ import java.util.Iterator; import java.util.Map; import java.util.concurrent.atomic.AtomicLong; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import org.jspecify.annotations.NonNull; +import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.logic.PosInOccurrence; @@ -66,7 +66,7 @@ public TacletAppIndex(TacletIndex tacletIndex, Goal goal, Services services) { } private TacletAppIndex(TacletIndex tacletIndex, SemisequentTacletAppIndex antecIndex, - SemisequentTacletAppIndex succIndex, @Nonnull Goal goal, State state, + SemisequentTacletAppIndex succIndex, @NonNull Goal goal, State state, RuleFilter ruleFilter, TermTacletAppIndexCacheSet indexCaches, Map cache) { this.tacletIndex = tacletIndex; diff --git a/key.core/src/main/java/de/uka/ilkd/key/proof/TacletIndex.java b/key.core/src/main/java/de/uka/ilkd/key/proof/TacletIndex.java index 077105d89c9..c5987273878 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/proof/TacletIndex.java +++ b/key.core/src/main/java/de/uka/ilkd/key/proof/TacletIndex.java @@ -1,7 +1,7 @@ package de.uka.ilkd.key.proof; import java.util.*; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.java.*; import de.uka.ilkd.key.java.statement.*; diff --git a/key.core/src/main/java/de/uka/ilkd/key/proof/init/InitConfig.java b/key.core/src/main/java/de/uka/ilkd/key/proof/init/InitConfig.java index 394edb3ad0c..c94f950cf10 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/proof/init/InitConfig.java +++ b/key.core/src/main/java/de/uka/ilkd/key/proof/init/InitConfig.java @@ -1,7 +1,7 @@ package de.uka.ilkd.key.proof.init; import java.util.*; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.logic.Choice; @@ -121,7 +121,7 @@ public Profile getProfile() { * * @return true if the default was successfully set */ - public boolean addCategoryDefaultChoice(@Nonnull String category, @Nonnull String choice) { + public boolean addCategoryDefaultChoice(@NonNull String category, @NonNull String choice) { if (!category2DefaultChoice.containsKey(category)) { category2DefaultChoice.put(category, choice); return true; @@ -132,7 +132,7 @@ public boolean addCategoryDefaultChoice(@Nonnull String category, @Nonnull Strin /** * Adds default choices given in {@code init}. Not overriding previous default choices. */ - public void addCategory2DefaultChoices(@Nonnull Map init) { + public void addCategory2DefaultChoices(@NonNull Map init) { boolean changed = false; for (final Map.Entry entry : init.entrySet()) { changed = addCategoryDefaultChoice(entry.getKey(), entry.getValue()) || changed; diff --git a/key.core/src/main/java/de/uka/ilkd/key/proof/init/KeYUserProblemFile.java b/key.core/src/main/java/de/uka/ilkd/key/proof/init/KeYUserProblemFile.java index 24f41d5ac50..30f08324147 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/proof/init/KeYUserProblemFile.java +++ b/key.core/src/main/java/de/uka/ilkd/key/proof/init/KeYUserProblemFile.java @@ -3,7 +3,7 @@ import java.io.File; import java.io.IOException; import java.net.URISyntaxException; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.java.abstraction.KeYJavaType; import de.uka.ilkd.key.logic.Term; @@ -239,7 +239,7 @@ public Profile getProfile() { * @throws Exception Occurred Exception. */ private Profile readProfileFromFile() throws Exception { - @Nonnull + @NonNull ProblemInformation pi = getProblemInformation(); String profileName = pi.getProfile(); if (profileName != null && !profileName.isEmpty()) { diff --git a/key.core/src/main/java/de/uka/ilkd/key/proof/io/EnvInput.java b/key.core/src/main/java/de/uka/ilkd/key/proof/io/EnvInput.java index d54e385e7d1..53011e48cc8 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/proof/io/EnvInput.java +++ b/key.core/src/main/java/de/uka/ilkd/key/proof/io/EnvInput.java @@ -3,8 +3,8 @@ import java.io.File; import java.io.IOException; import java.util.List; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import org.jspecify.annotations.NonNull; +import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.proof.init.Includes; import de.uka.ilkd.key.proof.init.InitConfig; @@ -60,7 +60,7 @@ public interface EnvInput { /** * gets the classpath elements to be considered here. */ - @Nonnull + @NonNull List readClassPath() throws ProofInputException; /** diff --git a/key.core/src/main/java/de/uka/ilkd/key/proof/io/FileRuleSource.java b/key.core/src/main/java/de/uka/ilkd/key/proof/io/FileRuleSource.java index 875b81d1940..3f1e903d19b 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/proof/io/FileRuleSource.java +++ b/key.core/src/main/java/de/uka/ilkd/key/proof/io/FileRuleSource.java @@ -4,7 +4,7 @@ import java.net.MalformedURLException; import java.net.URL; import java.util.Objects; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; import org.antlr.v4.runtime.CharStream; import org.antlr.v4.runtime.CharStreams; @@ -14,7 +14,7 @@ public class FileRuleSource extends RuleSource { /** * The non-null reference to the file from which rules are read. */ - protected @Nonnull final File ruleFile; + protected @NonNull final File ruleFile; private final long numberOfChars; @@ -29,7 +29,7 @@ public int getNumberOfBytes() { } @Override - public @Nonnull File file() { + public @NonNull File file() { return ruleFile; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/proof/io/IntermediateProofReplayer.java b/key.core/src/main/java/de/uka/ilkd/key/proof/io/IntermediateProofReplayer.java index b01b30f2231..254a43715ae 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/proof/io/IntermediateProofReplayer.java +++ b/key.core/src/main/java/de/uka/ilkd/key/proof/io/IntermediateProofReplayer.java @@ -5,7 +5,7 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.stream.Collectors; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.axiom_abstraction.AbstractDomainElement; import de.uka.ilkd.key.axiom_abstraction.predicateabstraction.AbstractPredicateAbstractionLattice; @@ -850,7 +850,7 @@ protected static ImmutableSet collectAppsForRule(String ruleNam * @param services The services object. * @return The instantiated taclet. */ - public static TacletApp constructInsts(@Nonnull TacletApp app, Goal currGoal, + public static TacletApp constructInsts(@NonNull TacletApp app, Goal currGoal, Collection loadedInsts, Services services) { if (loadedInsts == null) { return app; diff --git a/key.core/src/main/java/de/uka/ilkd/key/proof/io/KeYFile.java b/key.core/src/main/java/de/uka/ilkd/key/proof/io/KeYFile.java index 59e2b95f8c7..73bf201afc7 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/proof/io/KeYFile.java +++ b/key.core/src/main/java/de/uka/ilkd/key/proof/io/KeYFile.java @@ -11,8 +11,8 @@ import java.util.List; import java.util.Objects; import java.util.stream.Collectors; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import org.jspecify.annotations.NonNull; +import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.nparser.*; import de.uka.ilkd.key.nparser.builder.ContractsAndInvariantsFinder; @@ -223,7 +223,7 @@ public Includes readIncludes() throws ProofInputException { @Override public File readBootClassPath() { - @Nonnull + @NonNull ProblemInformation pi = getProblemInformation(); String bootClassPath = pi.getBootClassPath(); if (bootClassPath == null) { @@ -239,7 +239,7 @@ public File readBootClassPath() { return bootClassPathFile; } - protected @Nonnull ProblemInformation getProblemInformation() { + protected @NonNull ProblemInformation getProblemInformation() { if (problemInformation == null) { KeyAst.File ctx = getParseContext(); problemInformation = ctx.getProblemInformation(); @@ -248,10 +248,10 @@ public File readBootClassPath() { } - @Nonnull + @NonNull @Override public List readClassPath() { - @Nonnull + @NonNull ProblemInformation pi = getProblemInformation(); String parentDirectory = file.file().getParent(); List fileList = new ArrayList<>(); @@ -271,7 +271,7 @@ public List readClassPath() { @Override public String readJavaPath() throws ProofInputException { - @Nonnull + @NonNull ProblemInformation pi = getProblemInformation(); String javaPath = pi.getJavaSource(); if (javaPath != null) { @@ -335,7 +335,7 @@ public ImmutableSet readContracts() { return DefaultImmutableSet.nil(); } - @Nonnull + @NonNull protected ProblemFinder getProblemFinder() { if (problemFinder == null) { problemFinder = new ProblemFinder(initConfig.getServices(), initConfig.namespaces()); diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/AbstractBuiltInRuleApp.java b/key.core/src/main/java/de/uka/ilkd/key/rule/AbstractBuiltInRuleApp.java index 586f99ba980..17cbea675db 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/AbstractBuiltInRuleApp.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/AbstractBuiltInRuleApp.java @@ -3,7 +3,7 @@ import java.util.List; import java.util.Objects; import java.util.concurrent.atomic.AtomicLong; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.logic.PosInOccurrence; diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/BlockContractExternalRule.java b/key.core/src/main/java/de/uka/ilkd/key/rule/BlockContractExternalRule.java index e17048761ec..bc7da46d552 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/BlockContractExternalRule.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/BlockContractExternalRule.java @@ -2,7 +2,7 @@ import java.util.List; import java.util.Map; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.informationflow.proof.InfFlowCheckInfo; import de.uka.ilkd.key.java.Services; @@ -185,7 +185,7 @@ public boolean isApplicable(final Goal goal, final PosInOccurrence occurrence) { return !InfFlowCheckInfo.isInfFlow(goal) && super.isApplicable(goal, occurrence); } - @Nonnull + @NonNull @Override public ImmutableList apply(final Goal goal, final Services services, final RuleApp ruleApp) throws RuleAbortException { diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/BlockContractInternalRule.java b/key.core/src/main/java/de/uka/ilkd/key/rule/BlockContractInternalRule.java index 5e0a1ca5ae8..a484e267e3a 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/BlockContractInternalRule.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/BlockContractInternalRule.java @@ -2,7 +2,7 @@ import java.util.List; import java.util.Map; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.informationflow.proof.InfFlowCheckInfo; import de.uka.ilkd.key.java.Services; @@ -209,7 +209,7 @@ public BlockContractInternalBuiltInRuleApp createApp(final PosInOccurrence occur return new BlockContractInternalBuiltInRuleApp(this, occurrence); } - @Nonnull + @NonNull @Override public ImmutableList apply(final Goal goal, final Services services, final RuleApp ruleApp) throws RuleAbortException { diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/BuiltInRule.java b/key.core/src/main/java/de/uka/ilkd/key/rule/BuiltInRule.java index d23cacce6df..ff3f080c67d 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/BuiltInRule.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/BuiltInRule.java @@ -1,6 +1,6 @@ package de.uka.ilkd.key.rule; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.logic.PosInOccurrence; import de.uka.ilkd.key.logic.TermServices; diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/HasOrigin.java b/key.core/src/main/java/de/uka/ilkd/key/rule/HasOrigin.java index e2dcacf81ab..2c804055109 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/HasOrigin.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/HasOrigin.java @@ -1,6 +1,6 @@ package de.uka.ilkd.key.rule; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; /** * Classes with this interfaces provides a simple human-readable String where they came from. diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/JmlAssertRule.java b/key.core/src/main/java/de/uka/ilkd/key/rule/JmlAssertRule.java index 0ca181d3c60..709c1fcb66e 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/JmlAssertRule.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/JmlAssertRule.java @@ -1,7 +1,7 @@ package de.uka.ilkd.key.rule; import java.util.Optional; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.java.JavaTools; import de.uka.ilkd.key.java.Services; @@ -102,7 +102,7 @@ public IBuiltInRuleApp createApp(PosInOccurrence occurrence, TermServices servic return new JmlAssertBuiltInRuleApp(this, occurrence); } - @Nonnull + @NonNull @Override public ImmutableList apply(Goal goal, Services services, RuleApp ruleApp) throws RuleAbortException { diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/LoopApplyHeadRule.java b/key.core/src/main/java/de/uka/ilkd/key/rule/LoopApplyHeadRule.java index 24c0ea58720..5193dc54f2f 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/LoopApplyHeadRule.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/LoopApplyHeadRule.java @@ -1,6 +1,6 @@ package de.uka.ilkd.key.rule; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.java.StatementBlock; @@ -59,7 +59,7 @@ public class LoopApplyHeadRule implements BuiltInRule { */ public static final Name NAME = new Name("Loop Apply Head"); - @Nonnull + @NonNull @Override public ImmutableList apply(Goal goal, Services services, RuleApp application) throws RuleAbortException { diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/LoopContractExternalRule.java b/key.core/src/main/java/de/uka/ilkd/key/rule/LoopContractExternalRule.java index 0d479e33bbf..14a3d5c5a43 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/LoopContractExternalRule.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/LoopContractExternalRule.java @@ -2,7 +2,7 @@ import java.util.List; import java.util.Map; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.informationflow.proof.InfFlowCheckInfo; import de.uka.ilkd.key.java.Services; @@ -206,7 +206,7 @@ public boolean isApplicable(final Goal goal, final PosInOccurrence occurrence) { } } - @Nonnull + @NonNull @Override public ImmutableList apply(final Goal goal, final Services services, final RuleApp ruleApp) throws RuleAbortException { diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/LoopContractInternalRule.java b/key.core/src/main/java/de/uka/ilkd/key/rule/LoopContractInternalRule.java index 15546559e13..9cf1bce5d0b 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/LoopContractInternalRule.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/LoopContractInternalRule.java @@ -2,7 +2,7 @@ import java.util.List; import java.util.Map; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.logic.Name; @@ -253,7 +253,7 @@ public LoopContractInternalBuiltInRuleApp createApp(final PosInOccurrence occurr return new LoopContractInternalBuiltInRuleApp(this, occurrence); } - @Nonnull + @NonNull @Override public ImmutableList apply(final Goal goal, final Services services, final RuleApp ruleApp) throws RuleAbortException { diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/LoopScopeInvariantRule.java b/key.core/src/main/java/de/uka/ilkd/key/rule/LoopScopeInvariantRule.java index e5c4b86d439..d3c15080b67 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/LoopScopeInvariantRule.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/LoopScopeInvariantRule.java @@ -2,7 +2,7 @@ import java.util.ArrayList; import java.util.Optional; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.informationflow.proof.InfFlowCheckInfo; import de.uka.ilkd.key.java.KeYJavaASTFactory; @@ -133,7 +133,7 @@ public boolean isApplicable(Goal goal, PosInOccurrence pio) { && !(modality == Modality.BOX_TRANSACTION || modality == Modality.DIA_TRANSACTION); } - @Nonnull + @NonNull @Override public ImmutableList apply(Goal goal, Services services, RuleApp ruleApp) throws RuleAbortException { diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/OneStepSimplifier.java b/key.core/src/main/java/de/uka/ilkd/key/rule/OneStepSimplifier.java index 13ee4742c4e..80ad262360b 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/OneStepSimplifier.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/OneStepSimplifier.java @@ -6,7 +6,7 @@ import java.util.List; import java.util.Map; import java.util.Set; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.logic.Name; @@ -574,7 +574,7 @@ public boolean isApplicable(Goal goal, PosInOccurrence pio) { null); } - @Nonnull + @NonNull @Override public synchronized ImmutableList apply(Goal goal, Services services, RuleApp ruleApp) { diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/QueryExpand.java b/key.core/src/main/java/de/uka/ilkd/key/rule/QueryExpand.java index 099857a17a7..88a42d0ac87 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/QueryExpand.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/QueryExpand.java @@ -1,7 +1,7 @@ package de.uka.ilkd.key.rule; import java.util.*; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.java.*; import de.uka.ilkd.key.java.abstraction.KeYJavaType; @@ -54,7 +54,7 @@ public class QueryExpand implements BuiltInRule { private final WeakHashMap timeOfTerm = new WeakHashMap<>(DEFAULT_MAP_SIZE); - @Nonnull + @NonNull @Override public ImmutableList apply(Goal goal, Services services, RuleApp ruleApp) { diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/Rule.java b/key.core/src/main/java/de/uka/ilkd/key/rule/Rule.java index 96b20d54f85..5cc9e3e03c3 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/Rule.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/Rule.java @@ -3,7 +3,7 @@ */ package de.uka.ilkd.key.rule; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.logic.Name; @@ -24,7 +24,7 @@ public interface Rule extends HasOrigin { * application * @throws RuleAbortException when this rule was aborted */ - @Nonnull + @NonNull ImmutableList apply(Goal goal, Services services, RuleApp ruleApp) throws RuleAbortException; diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/RuleApp.java b/key.core/src/main/java/de/uka/ilkd/key/rule/RuleApp.java index b21ee91687f..f79bc9e214e 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/RuleApp.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/RuleApp.java @@ -4,7 +4,7 @@ package de.uka.ilkd.key.rule; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.logic.PosInOccurrence; diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/RuleKey.java b/key.core/src/main/java/de/uka/ilkd/key/rule/RuleKey.java index f236787756e..f057301237c 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/RuleKey.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/RuleKey.java @@ -1,6 +1,6 @@ package de.uka.ilkd.key.rule; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.logic.ChoiceExpr; import de.uka.ilkd.key.logic.Name; @@ -15,11 +15,11 @@ * {@link Taclet#equals(Object)} and {@link Taclet#hashCode()} method. */ public class RuleKey { - public final @Nonnull Name name; - public final @Nonnull ChoiceExpr choices; + public final @NonNull Name name; + public final @NonNull ChoiceExpr choices; public final Rule r; - RuleKey(@Nonnull Name name, @Nonnull ChoiceExpr choices, Rule r) { + RuleKey(@NonNull Name name, @NonNull ChoiceExpr choices, Rule r) { this.name = name; this.choices = choices; this.r = r; diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/Taclet.java b/key.core/src/main/java/de/uka/ilkd/key/rule/Taclet.java index 68781493f6d..0a96a4f7653 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/Taclet.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/Taclet.java @@ -1,8 +1,8 @@ package de.uka.ilkd.key.rule; import java.util.*; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import org.jspecify.annotations.NonNull; +import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.logic.*; @@ -929,7 +929,7 @@ public enum TacletOperation { * close-goal-taclet ( this.closeGoal () ), the first goal of the return list is the * goal that should be closed (with the constraint this taclet is applied under). */ - @Nonnull + @NonNull @Override public ImmutableList apply(Goal goal, Services services, RuleApp tacletApp) { return getExecutor().apply(goal, services, tacletApp); diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/TacletApp.java b/key.core/src/main/java/de/uka/ilkd/key/rule/TacletApp.java index 5aa3f59ea75..0ed9217f865 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/TacletApp.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/TacletApp.java @@ -2,7 +2,7 @@ import java.util.*; import java.util.concurrent.atomic.AtomicLong; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.java.*; import de.uka.ilkd.key.java.abstraction.KeYJavaType; diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/UseDependencyContractRule.java b/key.core/src/main/java/de/uka/ilkd/key/rule/UseDependencyContractRule.java index 7dce10d5489..9a401660994 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/UseDependencyContractRule.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/UseDependencyContractRule.java @@ -4,7 +4,7 @@ import java.util.LinkedList; import java.util.List; import java.util.Map; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.java.abstraction.KeYJavaType; @@ -368,7 +368,7 @@ public boolean isApplicable(Goal goal, PosInOccurrence pio) { } - @Nonnull + @NonNull @Override public ImmutableList apply(Goal goal, Services services, RuleApp ruleApp) { // collect information diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/UseOperationContractRule.java b/key.core/src/main/java/de/uka/ilkd/key/rule/UseOperationContractRule.java index 23c7c4ca642..5d3f7d2f77a 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/UseOperationContractRule.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/UseOperationContractRule.java @@ -3,7 +3,7 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.informationflow.proof.InfFlowCheckInfo; import de.uka.ilkd.key.informationflow.proof.InfFlowProof; @@ -550,7 +550,7 @@ public boolean isApplicable(Goal goal, PosInOccurrence pio) { return false; } - @Nonnull + @NonNull @Override public ImmutableList apply(Goal goal, Services services, RuleApp ruleApp) { final TermLabelState termLabelState = new TermLabelState(); diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/WhileInvariantRule.java b/key.core/src/main/java/de/uka/ilkd/key/rule/WhileInvariantRule.java index 638a03c13c6..409c4c1219d 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/WhileInvariantRule.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/WhileInvariantRule.java @@ -4,7 +4,7 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.informationflow.po.IFProofObligationVars; import de.uka.ilkd.key.informationflow.po.snippet.InfFlowPOSnippetFactory; @@ -697,7 +697,7 @@ private void setupWdGoal(final Goal goal, final LoopSpecification inv, final Ter } - @Nonnull + @NonNull @Override public ImmutableList apply(Goal goal, Services services, final RuleApp ruleApp) throws RuleAbortException { diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/merge/CloseAfterMerge.java b/key.core/src/main/java/de/uka/ilkd/key/rule/merge/CloseAfterMerge.java index fb041502e3d..b3d88080ad6 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/merge/CloseAfterMerge.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/merge/CloseAfterMerge.java @@ -6,7 +6,7 @@ import java.util.LinkedList; import java.util.Set; import java.util.stream.Collectors; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.logic.Name; @@ -88,7 +88,7 @@ public String displayName() { return DISPLAY_NAME; } - @Nonnull + @NonNull @Override public ImmutableList apply(final Goal goal, final Services services, final RuleApp ruleApp) throws RuleAbortException { diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/merge/MergeRule.java b/key.core/src/main/java/de/uka/ilkd/key/rule/merge/MergeRule.java index 300e00db2dc..48c93131373 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/merge/MergeRule.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/merge/MergeRule.java @@ -4,7 +4,7 @@ import java.util.HashMap; import java.util.Iterator; import java.util.LinkedHashSet; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.logic.JavaBlock; @@ -128,7 +128,7 @@ public String toString() { return displayName(); } - @Nonnull + @NonNull @Override public final ImmutableList apply(Goal goal, final Services services, RuleApp ruleApp) throws RuleAbortException { diff --git a/key.core/src/main/java/de/uka/ilkd/key/settings/AbstractPropertiesSettings.java b/key.core/src/main/java/de/uka/ilkd/key/settings/AbstractPropertiesSettings.java index ffe569431a7..d4435964641 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/settings/AbstractPropertiesSettings.java +++ b/key.core/src/main/java/de/uka/ilkd/key/settings/AbstractPropertiesSettings.java @@ -4,8 +4,8 @@ import java.util.*; import java.util.function.Function; import java.util.stream.Collectors; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import org.jspecify.annotations.NonNull; +import org.jspecify.annotations.Nullable; /** * A base class for own settings based on properties. @@ -51,7 +51,7 @@ private static String stringSetToString(Set set) { * @return a possible empty, list of strings * @see #stringListToString(List) */ - private static @Nonnull List parseStringList(@Nonnull String str) { + private static @NonNull List parseStringList(@NonNull String str) { // escape special chars (in particular the comma) return Arrays.stream(str.split(SET_DELIMITER)).map(SettingsConverter::decodeString) .collect(Collectors.toCollection(ArrayList::new)); @@ -61,7 +61,7 @@ private static String stringSetToString(Set set) { * @param seq a string list * @return the strings concatenated with {@link #SET_DELIMITER} */ - private static @Nonnull String stringListToString(@Nonnull List seq) { + private static @NonNull String stringListToString(@NonNull List seq) { // escape special chars (in particular the comma) return seq.stream().map(SettingsConverter::encodeString) .collect(Collectors.joining(SET_DELIMITER)); @@ -132,7 +132,7 @@ protected PropertyEntry> createStringSetProperty(String key, String * @param defValue a default value * @return returns a {@link PropertyEntry} */ - protected PropertyEntry> createStringListProperty(@Nonnull String key, + protected PropertyEntry> createStringListProperty(@NonNull String key, @Nullable String defValue) { PropertyEntry> pe = new DefaultPropertyEntry<>(key, parseStringList(defValue), AbstractPropertiesSettings::parseStringList, diff --git a/key.core/src/main/java/de/uka/ilkd/key/settings/ChoiceSettings.java b/key.core/src/main/java/de/uka/ilkd/key/settings/ChoiceSettings.java index c6bb6a59013..a93bd92fb01 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/settings/ChoiceSettings.java +++ b/key.core/src/main/java/de/uka/ilkd/key/settings/ChoiceSettings.java @@ -1,7 +1,7 @@ package de.uka.ilkd.key.settings; import java.util.*; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.logic.Choice; import de.uka.ilkd.key.logic.Name; @@ -60,7 +60,7 @@ public Map> getChoices() { *

* The method name is somewhat misleading. */ - @Nonnull + @NonNull public Map getDefaultChoices() { return Collections.unmodifiableMap(category2Default); } @@ -69,7 +69,7 @@ public Map getDefaultChoices() { /** * returns the current selected choices as an immutable set */ - @Nonnull + @NonNull public ImmutableSet getDefaultChoicesAsSet() { return choiceMap2choiceSet(category2Default); } diff --git a/key.core/src/main/java/de/uka/ilkd/key/settings/SettingsConverter.java b/key.core/src/main/java/de/uka/ilkd/key/settings/SettingsConverter.java index 97523f53a6e..5b644b96a63 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/settings/SettingsConverter.java +++ b/key.core/src/main/java/de/uka/ilkd/key/settings/SettingsConverter.java @@ -6,7 +6,7 @@ import java.util.Collection; import java.util.Properties; import java.util.stream.Collectors; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; import org.key_project.util.Streams; @@ -127,7 +127,7 @@ private static String convert(String str, boolean encode) { * @param str the String to decode * @return the decoded version of str */ - public static String decode(@Nonnull String str) { + public static String decode(@NonNull String str) { int i = str.indexOf(PREFIX); if (i == 0) { str = str.substring(PREFIX.length()); @@ -162,7 +162,7 @@ public static String decode(@Nonnull String str) { * @param str the String to encode * @return the encoded version of str */ - public static String encode(@Nonnull String str) { + public static String encode(@NonNull String str) { return PREFIX + encodeString(str) + POSTFIX; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/smt/RuleAppSMT.java b/key.core/src/main/java/de/uka/ilkd/key/smt/RuleAppSMT.java index 3e11102cc00..ac72c44409c 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/smt/RuleAppSMT.java +++ b/key.core/src/main/java/de/uka/ilkd/key/smt/RuleAppSMT.java @@ -1,6 +1,6 @@ package de.uka.ilkd.key.smt; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.logic.Name; @@ -101,7 +101,7 @@ public boolean isApplicable(Goal goal, PosInOccurrence pio) { } - @Nonnull + @NonNull @Override public ImmutableList apply(Goal goal, Services services, RuleApp ruleApp) { if (goal.proof().getInitConfig().getJustifInfo().getJustification(RULE) == null) { diff --git a/key.core/src/main/java/de/uka/ilkd/key/smt/SMTSolverImplementation.java b/key.core/src/main/java/de/uka/ilkd/key/smt/SMTSolverImplementation.java index b2cc395cc46..c04d4fc9e7d 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/smt/SMTSolverImplementation.java +++ b/key.core/src/main/java/de/uka/ilkd/key/smt/SMTSolverImplementation.java @@ -4,7 +4,7 @@ import java.util.Collection; import java.util.LinkedList; import java.util.concurrent.atomic.AtomicInteger; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.java.abstraction.KeYJavaType; @@ -52,7 +52,7 @@ public final class SMTSolverImplementation implements SMTSolver, Runnable { * the socket that handles solver results and interactively communicates with the running * external solver process */ - private final @Nonnull AbstractSolverSocket socket; + private final @NonNull AbstractSolverSocket socket; /** * the ModelExtractor used to generate counterexamples (only used for CE solver type) diff --git a/key.core/src/main/java/de/uka/ilkd/key/smt/SmtLib2Translator.java b/key.core/src/main/java/de/uka/ilkd/key/smt/SmtLib2Translator.java index c9c514f7cac..82447d3aef6 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/smt/SmtLib2Translator.java +++ b/key.core/src/main/java/de/uka/ilkd/key/smt/SmtLib2Translator.java @@ -1,7 +1,7 @@ package de.uka.ilkd.key.smt; import java.util.ArrayList; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.logic.sort.Sort; diff --git a/key.core/src/main/java/de/uka/ilkd/key/smt/VersionChecker.java b/key.core/src/main/java/de/uka/ilkd/key/smt/VersionChecker.java index 9851f3fd292..7424b51b176 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/smt/VersionChecker.java +++ b/key.core/src/main/java/de/uka/ilkd/key/smt/VersionChecker.java @@ -4,7 +4,7 @@ import java.io.InputStreamReader; import java.nio.charset.StandardCharsets; import java.util.concurrent.TimeUnit; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; /** * Little helper class that helps to check for the version of a solver. Mainly it provides a method diff --git a/key.core/src/main/java/de/uka/ilkd/key/smt/communication/AbstractSolverSocket.java b/key.core/src/main/java/de/uka/ilkd/key/smt/communication/AbstractSolverSocket.java index 86c9dad9b4d..be8a40965db 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/smt/communication/AbstractSolverSocket.java +++ b/key.core/src/main/java/de/uka/ilkd/key/smt/communication/AbstractSolverSocket.java @@ -1,7 +1,7 @@ package de.uka.ilkd.key.smt.communication; import java.io.IOException; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.smt.ModelExtractor; import de.uka.ilkd.key.smt.solvertypes.SolverType; @@ -47,7 +47,7 @@ public abstract class AbstractSolverSocket { * @param name the name of the solver in use * @param query the ModelExtractor used to extract a counterexample */ - protected AbstractSolverSocket(@Nonnull String name, ModelExtractor query) { + protected AbstractSolverSocket(@NonNull String name, ModelExtractor query) { this.name = name; this.query = query; } @@ -71,7 +71,7 @@ protected String getName() { * @param msg the message as String * @throws IOException if an I/O error occurs */ - public abstract void messageIncoming(@Nonnull Pipe pipe, @Nonnull String msg) + public abstract void messageIncoming(@NonNull Pipe pipe, @NonNull String msg) throws IOException; /** @@ -93,7 +93,7 @@ public String modifyProblem(String problem) { * solvers this can be null) * @return the newly created socket */ - public static @Nonnull AbstractSolverSocket createSocket(@Nonnull SolverType type, + public static @NonNull AbstractSolverSocket createSocket(@NonNull SolverType type, ModelExtractor query) { return type.getSocket(query); } diff --git a/key.core/src/main/java/de/uka/ilkd/key/smt/communication/CVC4Socket.java b/key.core/src/main/java/de/uka/ilkd/key/smt/communication/CVC4Socket.java index 1d4e6cfb903..f277d5309a4 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/smt/communication/CVC4Socket.java +++ b/key.core/src/main/java/de/uka/ilkd/key/smt/communication/CVC4Socket.java @@ -1,7 +1,7 @@ package de.uka.ilkd.key.smt.communication; import java.io.IOException; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.smt.ModelExtractor; import de.uka.ilkd.key.smt.SMTSolverResult; @@ -13,7 +13,7 @@ public CVC4Socket(String name, ModelExtractor query) { } @Override - public void messageIncoming(@Nonnull Pipe pipe, @Nonnull String msg) throws IOException { + public void messageIncoming(@NonNull Pipe pipe, @NonNull String msg) throws IOException { SolverCommunication sc = pipe.getSolverCommunication(); if ("".equals(msg.trim())) { return; diff --git a/key.core/src/main/java/de/uka/ilkd/key/smt/communication/CVC5Socket.java b/key.core/src/main/java/de/uka/ilkd/key/smt/communication/CVC5Socket.java index 82182a526bb..daecfaf10a9 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/smt/communication/CVC5Socket.java +++ b/key.core/src/main/java/de/uka/ilkd/key/smt/communication/CVC5Socket.java @@ -1,7 +1,7 @@ package de.uka.ilkd.key.smt.communication; import java.io.IOException; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.smt.ModelExtractor; import de.uka.ilkd.key.smt.SMTSolverResult; @@ -22,7 +22,7 @@ public CVC5Socket(String name, ModelExtractor query) { } @Override - public void messageIncoming(@Nonnull Pipe pipe, @Nonnull String msg) throws IOException { + public void messageIncoming(@NonNull Pipe pipe, @NonNull String msg) throws IOException { SolverCommunication sc = pipe.getSolverCommunication(); if ("".equals(msg.trim())) { return; diff --git a/key.core/src/main/java/de/uka/ilkd/key/smt/communication/ExternalProcessLauncher.java b/key.core/src/main/java/de/uka/ilkd/key/smt/communication/ExternalProcessLauncher.java index 0d28eeaa6e3..bb29bed3d19 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/smt/communication/ExternalProcessLauncher.java +++ b/key.core/src/main/java/de/uka/ilkd/key/smt/communication/ExternalProcessLauncher.java @@ -1,7 +1,7 @@ package de.uka.ilkd.key.smt.communication; import java.io.*; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; /** * This class is responsible for starting external processes: @@ -18,12 +18,12 @@ public class ExternalProcessLauncher { /** * the store of all messages send to and received from the external process */ - private final @Nonnull SolverCommunication session; + private final @NonNull SolverCommunication session; /** * the delimiters which separate the messages */ - private final @Nonnull String[] messageDelimiters; + private final @NonNull String[] messageDelimiters; /** * the external process @@ -41,8 +41,8 @@ public class ExternalProcessLauncher { * @param session the store for the messages send to and received from the process * @param messageDelimiters delimiters which separate the messages */ - public ExternalProcessLauncher(@Nonnull SolverCommunication session, - @Nonnull String[] messageDelimiters) { + public ExternalProcessLauncher(@NonNull SolverCommunication session, + @NonNull String[] messageDelimiters) { this.session = session; this.messageDelimiters = messageDelimiters; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/smt/communication/LegacyPipe.java b/key.core/src/main/java/de/uka/ilkd/key/smt/communication/LegacyPipe.java index f4daeedbc0c..1b4e57db859 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/smt/communication/LegacyPipe.java +++ b/key.core/src/main/java/de/uka/ilkd/key/smt/communication/LegacyPipe.java @@ -5,8 +5,8 @@ import java.nio.charset.StandardCharsets; import java.util.concurrent.BlockingQueue; import java.util.concurrent.LinkedBlockingQueue; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import org.jspecify.annotations.NonNull; +import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.smt.communication.SolverCommunication.Message; import de.uka.ilkd.key.smt.communication.SolverCommunication.MessageType; @@ -159,7 +159,7 @@ public void join() throws InterruptedException { } @Override - public synchronized void sendMessage(@Nonnull String message) throws IOException { + public synchronized void sendMessage(@NonNull String message) throws IOException { outputWriter.write(message + System.lineSeparator()); outputWriter.flush(); } @@ -191,7 +191,7 @@ public boolean isAlive() { return stderrReceiver.alive && stdoutReceiver.alive; } - public @Nonnull SolverCommunication getSolverCommunication() { + public @NonNull SolverCommunication getSolverCommunication() { return session; } } diff --git a/key.core/src/main/java/de/uka/ilkd/key/smt/communication/Pipe.java b/key.core/src/main/java/de/uka/ilkd/key/smt/communication/Pipe.java index 2126643f2f3..b9ede5bcc55 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/smt/communication/Pipe.java +++ b/key.core/src/main/java/de/uka/ilkd/key/smt/communication/Pipe.java @@ -1,8 +1,8 @@ package de.uka.ilkd.key.smt.communication; import java.io.IOException; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import org.jspecify.annotations.NonNull; +import org.jspecify.annotations.Nullable; /** * This interface describes a pipe for sending messages to or receiving them from an external SMT @@ -17,7 +17,7 @@ public interface Pipe { * @param message the message to send * @throws IOException if an I/O error occurs */ - void sendMessage(@Nonnull String message) throws IOException; + void sendMessage(@NonNull String message) throws IOException; /** * Reads a message from the external process. This method blocks until there is a further @@ -35,7 +35,7 @@ public interface Pipe { * * @return the data sent between KeY and solver until now */ - @Nonnull + @NonNull SolverCommunication getSolverCommunication(); /** diff --git a/key.core/src/main/java/de/uka/ilkd/key/smt/communication/SimplePipe.java b/key.core/src/main/java/de/uka/ilkd/key/smt/communication/SimplePipe.java index 325e4f7d617..f4b768908fd 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/smt/communication/SimplePipe.java +++ b/key.core/src/main/java/de/uka/ilkd/key/smt/communication/SimplePipe.java @@ -2,8 +2,8 @@ import java.io.*; import java.nio.charset.StandardCharsets; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import org.jspecify.annotations.NonNull; +import org.jspecify.annotations.Nullable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -20,22 +20,22 @@ public class SimplePipe implements Pipe { /** * The Reader that splits incoming messages at the given delimiters. */ - private final @Nonnull BufferedMessageReader reader; + private final @NonNull BufferedMessageReader reader; /** * */ - private final @Nonnull SolverCommunication session; + private final @NonNull SolverCommunication session; /** * The process this pipe is attached to. */ - private final @Nonnull Process process; + private final @NonNull Process process; /** * The Writer connected to stdin of the external process. */ - private final @Nonnull Writer smtIn; + private final @NonNull Writer smtIn; /** * Input of the SMT stdin @@ -69,9 +69,9 @@ public class SimplePipe implements Pipe { * @param session the message list where to log the messages to * @param process the external process this pipe is connected to */ - public SimplePipe(@Nonnull InputStream input, @Nonnull String[] messageDelimiters, - @Nonnull OutputStream output, @Nonnull SolverCommunication session, - @Nonnull Process process) { + public SimplePipe(@NonNull InputStream input, @NonNull String[] messageDelimiters, + @NonNull OutputStream output, @NonNull SolverCommunication session, + @NonNull Process process) { processWriter = new TeeWriter(new OutputStreamWriter(output, StandardCharsets.UTF_8), stdin); processReader = new TeeReader(new InputStreamReader(input, StandardCharsets.UTF_8), stdout); @@ -91,7 +91,7 @@ public String getReadMessages() { } @Override - public void sendMessage(@Nonnull String message) throws IOException { + public void sendMessage(@NonNull String message) throws IOException { try { session.addMessage(message, SolverCommunication.MessageType.INPUT); smtIn.write(message + System.lineSeparator()); @@ -124,7 +124,7 @@ public void tryToReadExhaustively() { } @Override - public @Nonnull SolverCommunication getSolverCommunication() { + public @NonNull SolverCommunication getSolverCommunication() { return session; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/smt/communication/TeeReader.java b/key.core/src/main/java/de/uka/ilkd/key/smt/communication/TeeReader.java index bf83e395b4c..57439046c19 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/smt/communication/TeeReader.java +++ b/key.core/src/main/java/de/uka/ilkd/key/smt/communication/TeeReader.java @@ -3,7 +3,7 @@ import java.io.IOException; import java.io.Reader; import java.io.Writer; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; /** * A {@link TeeReader} writes everything it reads to a separated writer. @@ -12,13 +12,13 @@ * @version 1 (10/3/21) */ public class TeeReader extends Reader { - @Nonnull + @NonNull private final Reader source; - @Nonnull + @NonNull private final Writer sink; - public TeeReader(@Nonnull Reader source, @Nonnull Writer sink) { + public TeeReader(@NonNull Reader source, @NonNull Writer sink) { this.source = source; this.sink = sink; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/smt/communication/TeeWriter.java b/key.core/src/main/java/de/uka/ilkd/key/smt/communication/TeeWriter.java index f3dd343acc2..ceb58b0c21b 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/smt/communication/TeeWriter.java +++ b/key.core/src/main/java/de/uka/ilkd/key/smt/communication/TeeWriter.java @@ -2,7 +2,7 @@ import java.io.IOException; import java.io.Writer; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; /** @@ -12,13 +12,13 @@ * @version 1 (10/3/21) */ public class TeeWriter extends Writer { - @Nonnull + @NonNull private final Writer source; - @Nonnull + @NonNull private final Writer sink; - public TeeWriter(@Nonnull Writer source, @Nonnull Writer sink) { + public TeeWriter(@NonNull Writer source, @NonNull Writer sink) { this.source = source; this.sink = sink; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/smt/communication/Z3CESocket.java b/key.core/src/main/java/de/uka/ilkd/key/smt/communication/Z3CESocket.java index ec2b22c9fb4..83805bdeb93 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/smt/communication/Z3CESocket.java +++ b/key.core/src/main/java/de/uka/ilkd/key/smt/communication/Z3CESocket.java @@ -1,7 +1,7 @@ package de.uka.ilkd.key.smt.communication; import java.io.IOException; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.smt.ModelExtractor; import de.uka.ilkd.key.smt.SMTSolverResult; @@ -13,7 +13,7 @@ public Z3CESocket(String name, ModelExtractor query) { } @Override - public void messageIncoming(@Nonnull Pipe pipe, @Nonnull String msg) throws IOException { + public void messageIncoming(@NonNull Pipe pipe, @NonNull String msg) throws IOException { SolverCommunication sc = pipe.getSolverCommunication(); if (msg.startsWith("(error")) { diff --git a/key.core/src/main/java/de/uka/ilkd/key/smt/communication/Z3Socket.java b/key.core/src/main/java/de/uka/ilkd/key/smt/communication/Z3Socket.java index 9aee24bb5fd..7723d866086 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/smt/communication/Z3Socket.java +++ b/key.core/src/main/java/de/uka/ilkd/key/smt/communication/Z3Socket.java @@ -1,7 +1,7 @@ package de.uka.ilkd.key.smt.communication; import java.io.IOException; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.smt.ModelExtractor; import de.uka.ilkd.key.smt.SMTSolverResult; @@ -13,7 +13,7 @@ public Z3Socket(String name, ModelExtractor query) { } @Override - public void messageIncoming(@Nonnull Pipe pipe, @Nonnull String msg) throws IOException { + public void messageIncoming(@NonNull Pipe pipe, @NonNull String msg) throws IOException { SolverCommunication sc = pipe.getSolverCommunication(); if (msg.startsWith("(error")) { sc.addMessage(msg, SolverCommunication.MessageType.ERROR); diff --git a/key.core/src/main/java/de/uka/ilkd/key/smt/newsmt2/MasterHandler.java b/key.core/src/main/java/de/uka/ilkd/key/smt/newsmt2/MasterHandler.java index a6a6c48a933..a22fa0995f6 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/smt/newsmt2/MasterHandler.java +++ b/key.core/src/main/java/de/uka/ilkd/key/smt/newsmt2/MasterHandler.java @@ -11,7 +11,7 @@ import java.util.Map.Entry; import java.util.Properties; import java.util.Set; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.logic.Term; diff --git a/key.core/src/main/java/de/uka/ilkd/key/smt/newsmt2/ModularSMTLib2Translator.java b/key.core/src/main/java/de/uka/ilkd/key/smt/newsmt2/ModularSMTLib2Translator.java index 01a373bda4a..1aea23b3160 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/smt/newsmt2/ModularSMTLib2Translator.java +++ b/key.core/src/main/java/de/uka/ilkd/key/smt/newsmt2/ModularSMTLib2Translator.java @@ -7,7 +7,7 @@ import java.util.Arrays; import java.util.LinkedList; import java.util.List; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.logic.Sequent; diff --git a/key.core/src/main/java/de/uka/ilkd/key/smt/newsmt2/SMTHandlerServices.java b/key.core/src/main/java/de/uka/ilkd/key/smt/newsmt2/SMTHandlerServices.java index 590d4378708..c3ffdc8b8ec 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/smt/newsmt2/SMTHandlerServices.java +++ b/key.core/src/main/java/de/uka/ilkd/key/smt/newsmt2/SMTHandlerServices.java @@ -9,7 +9,7 @@ import java.nio.charset.StandardCharsets; import java.util.*; import java.util.concurrent.ConcurrentHashMap; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.smt.solvertypes.SolverPropertiesLoader; @@ -173,7 +173,7 @@ private boolean findHandler(Class clazz, Collection resu * @throws IOException if the resources cannot be read */ - public List getFreshHandlers(Services services, @Nonnull String[] handlerNames, + public List getFreshHandlers(Services services, @NonNull String[] handlerNames, String[] handlerOptions, MasterHandler mh) throws IOException { List result = new ArrayList<>(); diff --git a/key.core/src/main/java/de/uka/ilkd/key/smt/solvertypes/SolverType.java b/key.core/src/main/java/de/uka/ilkd/key/smt/solvertypes/SolverType.java index ffa7ded34ae..520f5cb330c 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/smt/solvertypes/SolverType.java +++ b/key.core/src/main/java/de/uka/ilkd/key/smt/solvertypes/SolverType.java @@ -13,8 +13,8 @@ package de.uka.ilkd.key.smt.solvertypes; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import org.jspecify.annotations.NonNull; +import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.smt.*; @@ -198,7 +198,7 @@ public interface SolverType { * solvers this can be null) * @return the newly created socket */ - @Nonnull + @NonNull AbstractSolverSocket getSocket(ModelExtractor query); } diff --git a/key.core/src/main/java/de/uka/ilkd/key/smt/solvertypes/SolverTypeImplementation.java b/key.core/src/main/java/de/uka/ilkd/key/smt/solvertypes/SolverTypeImplementation.java index c7e9d9efcfa..9ea758b58db 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/smt/solvertypes/SolverTypeImplementation.java +++ b/key.core/src/main/java/de/uka/ilkd/key/smt/solvertypes/SolverTypeImplementation.java @@ -4,8 +4,8 @@ import java.lang.reflect.InvocationTargetException; import java.nio.file.Paths; import java.util.Arrays; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import org.jspecify.annotations.NonNull; +import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.smt.*; @@ -470,7 +470,7 @@ public boolean supportHasBeenChecked() { return supportHasBeenChecked; } - @Nonnull + @NonNull @Override public AbstractSolverSocket getSocket(ModelExtractor query) { AbstractSolverSocket socket = solverSocket.copy(); diff --git a/key.core/src/main/java/de/uka/ilkd/key/smt/solvertypes/SolverTypes.java b/key.core/src/main/java/de/uka/ilkd/key/smt/solvertypes/SolverTypes.java index 0420899116f..ec6a44329ef 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/smt/solvertypes/SolverTypes.java +++ b/key.core/src/main/java/de/uka/ilkd/key/smt/solvertypes/SolverTypes.java @@ -1,7 +1,7 @@ package de.uka.ilkd.key.smt.solvertypes; import java.util.*; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; /** * Facade for the management of {@link SolverType}. This class holds references to common and known @@ -35,7 +35,7 @@ private SolverTypes() { * * @return the available solver types, including legacy solvers */ - @Nonnull + @NonNull public static Collection getSolverTypes() { if (SOLVERS.isEmpty()) { SolverPropertiesLoader solverLoader = new SolverPropertiesLoader(); @@ -50,7 +50,7 @@ public static Collection getSolverTypes() { * * @return the available legacy solver types */ - @Nonnull + @NonNull public static Collection getLegacySolvers() { if (SOLVERS.isEmpty()) { getSolverTypes(); diff --git a/key.core/src/main/java/de/uka/ilkd/key/speclang/PositionedString.java b/key.core/src/main/java/de/uka/ilkd/key/speclang/PositionedString.java index 93e7c816b05..a41f87fa29b 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/speclang/PositionedString.java +++ b/key.core/src/main/java/de/uka/ilkd/key/speclang/PositionedString.java @@ -2,7 +2,7 @@ import java.net.URI; import java.util.Objects; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.java.Position; import de.uka.ilkd.key.logic.label.TermLabel; @@ -15,15 +15,15 @@ * used for error reporting. */ public class PositionedString { - @Nonnull + @NonNull public final String text; - @Nonnull + @NonNull public final Location location; private static final ImmutableArray EMPTY_LABEL_LIST = new ImmutableArray<>(); - public PositionedString(@Nonnull String text, @Nonnull Location location) { + public PositionedString(@NonNull String text, @NonNull Location location) { if (text == null || location == null) { throw new IllegalArgumentException(); } @@ -32,7 +32,7 @@ public PositionedString(@Nonnull String text, @Nonnull Location location) { this.location = location; } - public PositionedString(@Nonnull String text, URI fileName) { + public PositionedString(@NonNull String text, URI fileName) { this(text, new Location(fileName, Position.UNDEFINED)); } @@ -59,12 +59,12 @@ public String toString() { + location.getPosition() + ")"; } - @Nonnull + @NonNull public String getText() { return text; } - @Nonnull + @NonNull public Location getLocation() { return location; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/speclang/SpecificationElement.java b/key.core/src/main/java/de/uka/ilkd/key/speclang/SpecificationElement.java index eab3f577408..fd4604f01e4 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/speclang/SpecificationElement.java +++ b/key.core/src/main/java/de/uka/ilkd/key/speclang/SpecificationElement.java @@ -1,7 +1,7 @@ package de.uka.ilkd.key.speclang; import java.util.function.UnaryOperator; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.java.abstraction.KeYJavaType; diff --git a/key.core/src/main/java/de/uka/ilkd/key/speclang/jml/JMLInfoExtractor.java b/key.core/src/main/java/de/uka/ilkd/key/speclang/jml/JMLInfoExtractor.java index cf2bf6179d8..e6d531fb03e 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/speclang/jml/JMLInfoExtractor.java +++ b/key.core/src/main/java/de/uka/ilkd/key/speclang/jml/JMLInfoExtractor.java @@ -1,7 +1,7 @@ package de.uka.ilkd.key.speclang.jml; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import org.jspecify.annotations.NonNull; +import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.java.Comment; import de.uka.ilkd.key.java.abstraction.KeYJavaType; @@ -380,7 +380,7 @@ public static boolean isStrictlyPure(IProgramMethod pm) { * Returns the spec math mode of this type */ @Nullable - public static SpecMathMode getSpecMathMode(@Nonnull KeYJavaType t) { + public static SpecMathMode getSpecMathMode(@NonNull KeYJavaType t) { if (!(t.getJavaType() instanceof TypeDeclaration)) { return null; } else { @@ -388,7 +388,7 @@ public static SpecMathMode getSpecMathMode(@Nonnull KeYJavaType t) { } } - @Nonnull + @NonNull private static SpecMathMode modeOrDefault(@Nullable SpecMathMode mode) { return mode == null ? SpecMathMode.defaultMode() : mode; } @@ -396,8 +396,8 @@ private static SpecMathMode modeOrDefault(@Nullable SpecMathMode mode) { /** * Returns the spec math mode of this type or the default */ - @Nonnull - public static SpecMathMode getSpecMathModeOrDefault(@Nonnull KeYJavaType t) { + @NonNull + public static SpecMathMode getSpecMathModeOrDefault(@NonNull KeYJavaType t) { return modeOrDefault(getSpecMathMode(t)); } @@ -405,7 +405,7 @@ public static SpecMathMode getSpecMathModeOrDefault(@Nonnull KeYJavaType t) { * Returns the spec math mode of this method */ @Nullable - public static SpecMathMode getSpecMathMode(@Nonnull IProgramMethod pm) { + public static SpecMathMode getSpecMathMode(@NonNull IProgramMethod pm) { var methodMode = pm.getMethodDeclaration().getJmlModifiers().specMathMode; return methodMode != null ? methodMode : getSpecMathMode(pm.getContainerType()); } @@ -413,8 +413,8 @@ public static SpecMathMode getSpecMathMode(@Nonnull IProgramMethod pm) { /** * Returns the spec math mode of this method */ - @Nonnull - public static SpecMathMode getSpecMathModeOrDefault(@Nonnull IProgramMethod pm) { + @NonNull + public static SpecMathMode getSpecMathModeOrDefault(@NonNull IProgramMethod pm) { return modeOrDefault(getSpecMathMode(pm)); } } diff --git a/key.core/src/main/java/de/uka/ilkd/key/speclang/jml/JMLUtils.java b/key.core/src/main/java/de/uka/ilkd/key/speclang/jml/JMLUtils.java index cc29730d06d..714071370ff 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/speclang/jml/JMLUtils.java +++ b/key.core/src/main/java/de/uka/ilkd/key/speclang/jml/JMLUtils.java @@ -2,7 +2,7 @@ import java.util.Set; import java.util.TreeSet; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; @Deprecated public abstract class JMLUtils { @@ -18,7 +18,7 @@ public abstract class JMLUtils { * {@code @} sign or by the end of the string. It also is aware of potential comment starters, * i.e., "//" or "/*". */ - public static @Nonnull Set splitJmlMarker(@Nonnull String starter) { + public static @NonNull Set splitJmlMarker(@NonNull String starter) { Set features = new TreeSet<>(); int start = 0; if (starter.startsWith("//") || starter.startsWith("/*")) { @@ -42,7 +42,7 @@ public abstract class JMLUtils { *

* Uses {@link #KEY_TOOL_IDENTIFIER} as the marker for this KeY. */ - public static boolean isJmlCommentStarter(@Nonnull String starter) { + public static boolean isJmlCommentStarter(@NonNull String starter) { return isJmlCommentStarter(starter, KEY_TOOL_IDENTIFIER); } diff --git a/key.core/src/main/java/de/uka/ilkd/key/speclang/jml/pretranslation/TextualJMLConstruct.java b/key.core/src/main/java/de/uka/ilkd/key/speclang/jml/pretranslation/TextualJMLConstruct.java index b7dec57bc6e..eb2e4ab1e04 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/speclang/jml/pretranslation/TextualJMLConstruct.java +++ b/key.core/src/main/java/de/uka/ilkd/key/speclang/jml/pretranslation/TextualJMLConstruct.java @@ -3,7 +3,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.java.Position; import de.uka.ilkd.key.ldt.HeapLDT; @@ -99,7 +99,7 @@ protected void setPosition(LabeledParserRuleContext ps) { */ @Deprecated protected void addGeneric(Map> item, - @Nonnull LabeledParserRuleContext ps) { + @NonNull LabeledParserRuleContext ps) { String t = ps.first.getText(); if (!t.startsWith("<") || t.startsWith("") || t.startsWith("")) { ImmutableList l = item.get(HeapLDT.BASE_HEAP_NAME.toString()); diff --git a/key.core/src/main/java/de/uka/ilkd/key/speclang/jml/pretranslation/TextualJMLDepends.java b/key.core/src/main/java/de/uka/ilkd/key/speclang/jml/pretranslation/TextualJMLDepends.java index 9df11e30f49..b8b588385f8 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/speclang/jml/pretranslation/TextualJMLDepends.java +++ b/key.core/src/main/java/de/uka/ilkd/key/speclang/jml/pretranslation/TextualJMLDepends.java @@ -2,7 +2,7 @@ import java.util.LinkedHashMap; import java.util.Map; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.ldt.HeapLDT; import de.uka.ilkd.key.logic.Name; @@ -21,7 +21,7 @@ public final class TextualJMLDepends extends TextualJMLConstruct { new LinkedHashMap<>(); public TextualJMLDepends(ImmutableList mods, Name[] heaps, - @Nonnull LabeledParserRuleContext depends) { + @NonNull LabeledParserRuleContext depends) { super(mods); setPosition(depends); for (Name hName : HeapLDT.VALID_HEAP_NAMES) { diff --git a/key.core/src/main/java/de/uka/ilkd/key/speclang/jml/pretranslation/TextualJMLLoopSpec.java b/key.core/src/main/java/de/uka/ilkd/key/speclang/jml/pretranslation/TextualJMLLoopSpec.java index dec0bee9baa..f9db3f56b4e 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/speclang/jml/pretranslation/TextualJMLLoopSpec.java +++ b/key.core/src/main/java/de/uka/ilkd/key/speclang/jml/pretranslation/TextualJMLLoopSpec.java @@ -2,7 +2,7 @@ import java.util.*; import java.util.stream.Collectors; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.ldt.HeapLDT; import de.uka.ilkd.key.logic.Name; diff --git a/key.core/src/main/java/de/uka/ilkd/key/speclang/jml/pretranslation/TextualJMLMergePointDecl.java b/key.core/src/main/java/de/uka/ilkd/key/speclang/jml/pretranslation/TextualJMLMergePointDecl.java index a5c97a1b32f..8092e3abd2f 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/speclang/jml/pretranslation/TextualJMLMergePointDecl.java +++ b/key.core/src/main/java/de/uka/ilkd/key/speclang/jml/pretranslation/TextualJMLMergePointDecl.java @@ -1,7 +1,7 @@ package de.uka.ilkd.key.speclang.jml.pretranslation; import java.util.Objects; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.speclang.njml.JmlParser; @@ -15,16 +15,16 @@ * @author Dominic Scheurer */ public final class TextualJMLMergePointDecl extends TextualJMLConstruct { - private final @Nonnull JmlParser.Merge_point_statementContext mergeProc; + private final @NonNull JmlParser.Merge_point_statementContext mergeProc; - public TextualJMLMergePointDecl(@Nonnull ImmutableList mods, - @Nonnull JmlParser.Merge_point_statementContext mergeProc) { + public TextualJMLMergePointDecl(@NonNull ImmutableList mods, + @NonNull JmlParser.Merge_point_statementContext mergeProc) { super(mods); this.mergeProc = mergeProc; setPosition(mergeProc); } - public @Nonnull JmlParser.Merge_point_statementContext getMergeProc() { + public @NonNull JmlParser.Merge_point_statementContext getMergeProc() { return mergeProc; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/speclang/jml/pretranslation/TextualJMLSpecCase.java b/key.core/src/main/java/de/uka/ilkd/key/speclang/jml/pretranslation/TextualJMLSpecCase.java index 2bd5fb3447b..b5b0d085bcb 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/speclang/jml/pretranslation/TextualJMLSpecCase.java +++ b/key.core/src/main/java/de/uka/ilkd/key/speclang/jml/pretranslation/TextualJMLSpecCase.java @@ -4,14 +4,15 @@ import java.util.List; import java.util.Objects; import java.util.stream.Collectors; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import org.jspecify.annotations.NonNull; +import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.ldt.HeapLDT; import de.uka.ilkd.key.logic.Name; import de.uka.ilkd.key.speclang.njml.LabeledParserRuleContext; import de.uka.ilkd.key.util.Triple; +import org.jspecify.annotations.Nullable; import org.key_project.util.collection.ImmutableList; import org.antlr.v4.runtime.ParserRuleContext; @@ -37,8 +38,8 @@ public ImmutableList getAssignableFree(Name toString) return getList(ASSIGNABLE_FREE, toString); } - private ImmutableList getList(@Nonnull ClauseHd clause, - @Nonnull Name heap) { + private ImmutableList getList(@NonNull ClauseHd clause, + @NonNull Name heap) { List seq = clauses.stream().filter(it -> it.clauseType.equals(clause)) .filter(it -> Objects.equals(it.heap, heap)).map(it -> it.ctx) @@ -105,7 +106,7 @@ static class Entry { } } - public TextualJMLSpecCase(ImmutableList mods, @Nonnull Behavior behavior) { + public TextualJMLSpecCase(ImmutableList mods, @NonNull Behavior behavior) { super(mods); if (behavior == null) { throw new IllegalArgumentException(); @@ -153,14 +154,14 @@ public TextualJMLSpecCase addClause(ClauseHd clause, @Nullable Name heapName, * * @param other */ - public @Nonnull TextualJMLSpecCase merge(@Nonnull TextualJMLSpecCase other) { + public @NonNull TextualJMLSpecCase merge(@NonNull TextualJMLSpecCase other) { TextualJMLSpecCase res = clone(); res.clauses.addAll(other.clauses); return res; } @Override - public @Nonnull TextualJMLSpecCase clone() { + public @NonNull TextualJMLSpecCase clone() { TextualJMLSpecCase res = new TextualJMLSpecCase(getMods(), getBehavior()); res.name = name; res.clauses = new ArrayList<>(clauses); diff --git a/key.core/src/main/java/de/uka/ilkd/key/speclang/jml/translation/Context.java b/key.core/src/main/java/de/uka/ilkd/key/speclang/jml/translation/Context.java index 4503bf739db..98edca38e79 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/speclang/jml/translation/Context.java +++ b/key.core/src/main/java/de/uka/ilkd/key/speclang/jml/translation/Context.java @@ -1,7 +1,7 @@ package de.uka.ilkd.key.speclang.jml.translation; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import org.jspecify.annotations.NonNull; +import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.java.abstraction.KeYJavaType; import de.uka.ilkd.key.logic.TermBuilder; @@ -38,7 +38,7 @@ public class Context { * @param classType class * @param selfVar self variable */ - public Context(@Nonnull SpecMathMode specMathMode, @Nonnull KeYJavaType classType, + public Context(@NonNull SpecMathMode specMathMode, @NonNull KeYJavaType classType, ProgramVariable selfVar) { this.classType = classType; this.specMathMode = specMathMode; @@ -64,7 +64,7 @@ private static ProgramVariable createSelfVar(TermBuilder tb, KeYJavaType classTy * @param pm program method * @param tb term builder */ - public static Context inMethod(@Nonnull IProgramMethod pm, TermBuilder tb) { + public static Context inMethod(@NonNull IProgramMethod pm, TermBuilder tb) { var classType = pm.getContainerType(); var selfVar = createSelfVar(tb, classType, pm.isStatic()); return Context.inMethodWithSelfVar(pm, selfVar); @@ -76,7 +76,7 @@ public static Context inMethod(@Nonnull IProgramMethod pm, TermBuilder tb) { * @param pm program method * @param selfVar self var */ - public static Context inMethodWithSelfVar(@Nonnull IProgramMethod pm, ProgramVariable selfVar) { + public static Context inMethodWithSelfVar(@NonNull IProgramMethod pm, ProgramVariable selfVar) { var mode = JMLInfoExtractor.getSpecMathModeOrDefault(pm); return new Context(mode, pm.getContainerType(), selfVar); } @@ -88,7 +88,7 @@ public static Context inMethodWithSelfVar(@Nonnull IProgramMethod pm, ProgramVar * @param isStaticContext whether this is a static context * @param tb term builder */ - public static Context inClass(@Nonnull KeYJavaType classType, boolean isStaticContext, + public static Context inClass(@NonNull KeYJavaType classType, boolean isStaticContext, TermBuilder tb) { var selfVar = createSelfVar(tb, classType, isStaticContext); var mode = JMLInfoExtractor.getSpecMathModeOrDefault(classType); diff --git a/key.core/src/main/java/de/uka/ilkd/key/speclang/jml/translation/JMLSpecFactory.java b/key.core/src/main/java/de/uka/ilkd/key/speclang/jml/translation/JMLSpecFactory.java index 4f4a2b863df..d50f4e8a9e3 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/speclang/jml/translation/JMLSpecFactory.java +++ b/key.core/src/main/java/de/uka/ilkd/key/speclang/jml/translation/JMLSpecFactory.java @@ -3,8 +3,8 @@ import java.util.*; import java.util.stream.Collectors; import java.util.stream.Stream; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import org.jspecify.annotations.NonNull; +import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.axiom_abstraction.predicateabstraction.AbstractionPredicate; import de.uka.ilkd.key.java.*; @@ -521,13 +521,13 @@ private void translateAssignable(Context context, ProgramVariableCollection prog } - @Nonnull + @NonNull private LabeledParserRuleContext getAssignableNothing() { return new LabeledParserRuleContext(JmlFacade.parseClause("assignable \\nothing;"), ParameterlessTermLabel.IMPLICIT_SPECIFICATION_LABEL); } - @Nonnull + @NonNull private LabeledParserRuleContext getAssignableFreeNothing() { return new LabeledParserRuleContext(JmlFacade.parseClause("assignable_free \\nothing;"), ParameterlessTermLabel.IMPLICIT_SPECIFICATION_LABEL); @@ -1002,9 +1002,9 @@ private ImmutableSet createDependencyOperationContract(IProgramMethod // ------------------------------------------------------------------------- // public interface // ------------------------------------------------------------------------- - public ClassInvariant createJMLClassInvariant(@Nonnull KeYJavaType kjt, + public ClassInvariant createJMLClassInvariant(@NonNull KeYJavaType kjt, VisibilityModifier visibility, boolean isStatic, - @Nonnull LabeledParserRuleContext originalInv) { + @NonNull LabeledParserRuleContext originalInv) { var context = Context.inClass(kjt, isStatic, tb); // translateToTerm expression @@ -1037,8 +1037,8 @@ public ClassInvariant createJMLClassInvariant(KeYJavaType kjt, TextualJMLClassIn context.selfVar, textualInv.isFree()); } - public InitiallyClause createJMLInitiallyClause(@Nonnull KeYJavaType kjt, - VisibilityModifier visibility, @Nonnull LabeledParserRuleContext original) { + public InitiallyClause createJMLInitiallyClause(@NonNull KeYJavaType kjt, + VisibilityModifier visibility, @NonNull LabeledParserRuleContext original) { var context = Context.inClass(kjt, false, tb); // translateToTerm expression @@ -1058,8 +1058,8 @@ public InitiallyClause createJMLInitiallyClause(KeYJavaType kjt, return createJMLInitiallyClause(kjt, getVisibility(textualInv), textualInv.getInv()); } - public ClassAxiom createJMLRepresents(@Nonnull KeYJavaType kjt, VisibilityModifier visibility, - @Nonnull LabeledParserRuleContext originalRep, boolean isStatic) + public ClassAxiom createJMLRepresents(@NonNull KeYJavaType kjt, VisibilityModifier visibility, + @NonNull LabeledParserRuleContext originalRep, boolean isStatic) throws SLTranslationException { var context = Context.inClass(kjt, isStatic, tb); @@ -1118,7 +1118,7 @@ public ClassAxiom createJMLRepresents(KeYJavaType kjt, TextualJMLRepresents text * @param textual textual representation * @return created {@link ClassAxiom} */ - public ClassAxiom createJMLClassAxiom(@Nonnull KeYJavaType kjt, TextualJMLClassAxiom textual) { + public ClassAxiom createJMLClassAxiom(@NonNull KeYJavaType kjt, TextualJMLClassAxiom textual) { LabeledParserRuleContext originalRep = textual.getAxiom(); if (originalRep == null) { throw new NullPointerException(); diff --git a/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/ContractClauses.java b/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/ContractClauses.java index 0b97d253657..a007b938ed0 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/ContractClauses.java +++ b/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/ContractClauses.java @@ -4,7 +4,7 @@ import java.util.List; import java.util.Map; import java.util.stream.Collectors; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.java.Label; import de.uka.ilkd.key.logic.Term; diff --git a/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/DoubleHandler.java b/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/DoubleHandler.java index de036323e83..161af5321c4 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/DoubleHandler.java +++ b/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/DoubleHandler.java @@ -2,7 +2,7 @@ import java.util.EnumMap; import java.util.Map; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.java.abstraction.KeYJavaType; diff --git a/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/FloatHandler.java b/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/FloatHandler.java index f60dcde7895..6744450593d 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/FloatHandler.java +++ b/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/FloatHandler.java @@ -2,7 +2,7 @@ import java.util.EnumMap; import java.util.Map; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.java.abstraction.KeYJavaType; diff --git a/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/IntegerHandler.java b/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/IntegerHandler.java index 4b7a0e4f26a..4915354e81f 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/IntegerHandler.java +++ b/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/IntegerHandler.java @@ -3,7 +3,7 @@ import java.util.EnumMap; import java.util.IdentityHashMap; import java.util.Map; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.java.abstraction.PrimitiveType; diff --git a/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/JmlCheck.java b/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/JmlCheck.java index 01f3bc62de0..2a1435e262f 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/JmlCheck.java +++ b/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/JmlCheck.java @@ -1,7 +1,7 @@ package de.uka.ilkd.key.speclang.njml; import java.util.List; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.speclang.PositionedString; @@ -20,6 +20,6 @@ public interface JmlCheck { * @param ctx an arbitrary {@link ParserRuleContext} from the {@link JmlParser} * @return a potential empty list of warnings */ - @Nonnull - List check(@Nonnull ParserRuleContext ctx); + @NonNull + List check(@NonNull ParserRuleContext ctx); } diff --git a/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/JmlChecks.java b/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/JmlChecks.java index 96009eed1b9..c11baae7e60 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/JmlChecks.java +++ b/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/JmlChecks.java @@ -3,7 +3,7 @@ import java.util.ArrayList; import java.util.LinkedList; import java.util.List; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.parser.Location; import de.uka.ilkd.key.speclang.PositionedString; @@ -43,7 +43,7 @@ class AbstractCheck extends JmlParserBaseVisitor implements JmlCheck { private final List warnings = new LinkedList<>(); @Override - public @Nonnull List check(@Nonnull ParserRuleContext ctx) { + public @NonNull List check(@NonNull ParserRuleContext ctx) { warnings.clear(); ctx.accept(this); return warnings; diff --git a/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/JmlFacade.java b/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/JmlFacade.java index 651d29ec6b1..6674fdd83fc 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/JmlFacade.java +++ b/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/JmlFacade.java @@ -1,7 +1,7 @@ package de.uka.ilkd.key.speclang.njml; import java.net.URI; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.java.Position; import de.uka.ilkd.key.speclang.PositionedString; @@ -32,7 +32,7 @@ private JmlFacade() { /** * Creates an JML lexer for the give stream. */ - public static @Nonnull JmlLexer createLexer(@Nonnull CharStream stream) { + public static @NonNull JmlLexer createLexer(@NonNull CharStream stream) { return new JmlLexer(stream); } @@ -40,7 +40,7 @@ private JmlFacade() { * Creates a JML lexer for the given string with position. The position information of the lexer * is changed accordingly. */ - public static @Nonnull JmlLexer createLexer(@Nonnull PositionedString ps) { + public static @NonNull JmlLexer createLexer(@NonNull PositionedString ps) { CharStream result = CharStreams.fromString(ps.text, ps.getLocation().getFileURI().map(URI::toString).orElse(null)); JmlLexer lexer = createLexer(result); @@ -55,7 +55,7 @@ private JmlFacade() { /** * Creates a JML lexer for a given string. */ - public static @Nonnull JmlLexer createLexer(@Nonnull String content) { + public static @NonNull JmlLexer createLexer(@NonNull String content) { return createLexer(CharStreams.fromString(content)); } @@ -63,7 +63,7 @@ private JmlFacade() { * Parse the given string as an JML expr. Position information are updated accordingly to the * position given with the string. */ - public static @Nonnull ParserRuleContext parseExpr(@Nonnull PositionedString expr) { + public static @NonNull ParserRuleContext parseExpr(@NonNull PositionedString expr) { return getExpressionContext(createLexer(expr)); } @@ -96,7 +96,7 @@ private static ParserRuleContext getExpressionContext(JmlLexer lexer) { * * @see SyntaxErrorReporter */ - public static @Nonnull JmlParser createParser(@Nonnull JmlLexer lexer) { + public static @NonNull JmlParser createParser(@NonNull JmlLexer lexer) { JmlParser p = new JmlParser(new CommonTokenStream(lexer)); p.addErrorListener(p.getErrorReporter()); return p; @@ -105,7 +105,7 @@ private static ParserRuleContext getExpressionContext(JmlLexer lexer) { /** * Parses a given clause, like {@code ensures} or {@code requires} and returns a parse tree. */ - public static @Nonnull ParserRuleContext parseClause(@Nonnull String content) { + public static @NonNull ParserRuleContext parseClause(@NonNull String content) { JmlParser p = createParser(createLexer(content)); JmlParser.ClauseContext ctx = p.clauseEOF().clause(); p.getErrorReporter().throwException(); diff --git a/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/JmlIO.java b/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/JmlIO.java index 123eee30f74..287c101ed56 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/JmlIO.java +++ b/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/JmlIO.java @@ -1,8 +1,8 @@ package de.uka.ilkd.key.speclang.njml; import java.util.Map; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import org.jspecify.annotations.NonNull; +import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.java.Label; import de.uka.ilkd.key.java.Services; @@ -81,7 +81,7 @@ public JmlIO(Services services) { * @param atPres i do not know * @param atBefores i do not know */ - public JmlIO(@Nonnull Services services, @Nullable KeYJavaType specInClass, + public JmlIO(@NonNull Services services, @Nullable KeYJavaType specInClass, @Nullable ProgramVariable selfVar, @Nullable ImmutableList paramVars, @Nullable ProgramVariable resultVar, @Nullable ProgramVariable excVar, @Nullable Map atPres, @@ -117,8 +117,8 @@ public Pair translateRepresents(ParserRuleContext claus * * @throws ClassCastException if unsuitable parser rule context is given@param clause */ - public @Nonnull Pair translateRepresents( - @Nonnull LabeledParserRuleContext clause) { + public @NonNull Pair translateRepresents( + @NonNull LabeledParserRuleContext clause) { Pair p = translateRepresents(clause.first); return new Pair<>(p.first, p.second); } @@ -184,7 +184,7 @@ private Object interpret(ParserRuleContext ctx) { /** * Interpret the given parse tree as an JML expression in the current context. */ - public @Nonnull Term translateTerm(@Nonnull ParserRuleContext expr) { + public @NonNull Term translateTerm(@NonNull ParserRuleContext expr) { Object interpret = interpret(expr); if (interpret instanceof SLExpression) { return ((SLExpression) interpret).getTerm(); @@ -266,7 +266,7 @@ public Term parseExpression(String input) { * @return a information flow specification from the given context. * @throws ClassCastException if the {@code expr} is not suitable */ - public @Nonnull InfFlowSpec translateInfFlow(@Nonnull ParserRuleContext expr) { + public @NonNull InfFlowSpec translateInfFlow(@NonNull ParserRuleContext expr) { return (InfFlowSpec) this.interpret(expr); } @@ -319,7 +319,7 @@ public JmlIO selfVar(ProgramVariable selfVar) { /** * Sets the spec math mode. */ - public JmlIO specMathMode(@Nonnull SpecMathMode specMathMode) { + public JmlIO specMathMode(@NonNull SpecMathMode specMathMode) { this.specMathMode = specMathMode; return this; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/JmlMarkerDecision.java b/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/JmlMarkerDecision.java index 945aaef36f0..2ce1f1b3cd6 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/JmlMarkerDecision.java +++ b/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/JmlMarkerDecision.java @@ -5,7 +5,7 @@ import java.util.HashSet; import java.util.Set; import java.util.stream.Collectors; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; /** * Externalize algorithm to decide whether a JML comment is active given a set of enabled keys. @@ -34,7 +34,7 @@ public JmlMarkerDecision(JmlLexer lexer) { * * @param markers a collection of keys without prefix ([+-]) */ - public void setEnabledKeys(@Nonnull Collection markers) { + public void setEnabledKeys(@NonNull Collection markers) { this.enabledKeys = markers.stream().map(String::toLowerCase).collect(Collectors.toSet()); } diff --git a/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/JmlTermFactory.java b/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/JmlTermFactory.java index 815bef7915a..d0254278e36 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/JmlTermFactory.java +++ b/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/JmlTermFactory.java @@ -2,8 +2,8 @@ import java.util.*; import java.util.function.BiFunction; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import org.jspecify.annotations.NonNull; +import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.java.JavaInfo; import de.uka.ilkd.key.java.Label; @@ -219,7 +219,7 @@ public SLExpression quantifiedMax(Term _guard, Term body, KeYJavaType declsType, return new SLExpression(max, type); } - public @Nonnull SLExpression quantifiedNumOf(@Nullable Term t1, Term t2, KeYJavaType declsType, + public @NonNull SLExpression quantifiedNumOf(@Nullable Term t1, Term t2, KeYJavaType declsType, boolean nullable, Iterable qvs, KeYJavaType resultType) { BoundedNumericalQuantifier bounded = (qv, lo, hi, body) -> { final Term cond = tb.ife(tb.convertToFormula(body), tb.one(), tb.zero()); @@ -233,7 +233,7 @@ public SLExpression quantifiedMax(Term _guard, Term body, KeYJavaType declsType, return numeralQuantifier(declsType, nullable, qvs, t1, t2, resultType, unbounded, bounded); } - public @Nonnull SLExpression quantifiedProduct(KeYJavaType declsType, boolean nullable, + public @NonNull SLExpression quantifiedProduct(KeYJavaType declsType, boolean nullable, Iterable qvs, @Nullable Term t1, Term t2, KeYJavaType resultType) { BoundedNumericalQuantifier bounded = (qv, lo, hi, body) -> tb.bprod(qv, lo, hi, body, services); @@ -245,7 +245,7 @@ public SLExpression quantifiedMax(Term _guard, Term body, KeYJavaType declsType, return numeralQuantifier(declsType, nullable, qvs, t1, t2, resultType, unbounded, bounded); } - public @Nonnull SLExpression quantifiedSum(KeYJavaType javaType, boolean nullable, + public @NonNull SLExpression quantifiedSum(KeYJavaType javaType, boolean nullable, Iterable qvs, @Nullable Term t1, Term t2, KeYJavaType resultType) { BoundedNumericalQuantifier bounded = tb::bsum; UnboundedNumericalQuantifier unbounded = (declsType, n, vars, range, body) -> { @@ -350,7 +350,7 @@ public Term upperBound(Term a, LogicVariable lv) { return null; } - private @Nonnull SLExpression numeralQuantifier(KeYJavaType declsType, boolean nullable, + private @NonNull SLExpression numeralQuantifier(KeYJavaType declsType, boolean nullable, Iterable qvs, Term t1, Term t2, @Nullable KeYJavaType resultType, UnboundedNumericalQuantifier unbounded, BoundedNumericalQuantifier bounded) { Iterator it = qvs.iterator(); @@ -384,7 +384,7 @@ public Term notModified(Term term, SLExpression t) { return null; } - @Nonnull + @NonNull public SLExpression binary(OverloadedOperatorHandler.JMLOperator jmlOperator, SLExpression left, SLExpression right) { try { @@ -427,7 +427,7 @@ private interface BoundedNumericalQuantifier { // endregion - @Nonnull + @NonNull public SLExpression arrayRef(SLExpression receiver, String fullyQualifiedName, SLExpression rangeFrom, SLExpression rangeTo) { SLExpression result; @@ -824,7 +824,7 @@ public SLExpression values(KeYJavaType t) { * Need to handle this one differently from INV_FOR since here static invariants may occur too. * For a static invariant, take the passed type as receiver. */ - @Nonnull + @NonNull public SLExpression createInv(Term selfVar, KeYJavaType targetType) { final boolean isStatic = selfVar == null; assert targetType != null || !isStatic; @@ -836,7 +836,7 @@ public SLExpression createInv(Term selfVar, KeYJavaType targetType) { * Need to handle this one differently from INV_FREE_FOR since here static invariants may occur * too. For a static invariant, take the passed type as receiver. */ - @Nonnull + @NonNull public SLExpression createInvFree(Term selfVar, KeYJavaType targetType) { final boolean isStatic = selfVar == null; assert targetType != null || !isStatic; @@ -951,7 +951,7 @@ public SLExpression seqConcat(Term seq1, Term seq2) { return new SLExpression(tb.seqConcat(seq1, seq2), seqtype); } - @Nonnull + @NonNull public SLExpression seqGet(Term seq, Term idx) { return new SLExpression(tb.seqGet(Sort.ANY, seq, idx)); } @@ -976,15 +976,15 @@ public SLExpression createIndexOf(Term seq, Term elem) { return new SLExpression(tb.indexOf(seq, elem), inttype); } - public @Nonnull Term createReturns(@Nullable Term term) { + public @NonNull Term createReturns(@Nullable Term term) { return term == null ? tb.tt() : tb.convertToFormula(term); } - public @Nonnull Pair createContinues(Term term, String label) { + public @NonNull Pair createContinues(Term term, String label) { return createBreaks(term, label); } - @Nonnull + @NonNull public Pair createBreaks(Term term, String label) { Term formula = term == null ? tb.tt() : tb.convertToFormula(term); return new Pair<>(label == null ? null : new ProgramElementName(label), formula); @@ -1050,11 +1050,11 @@ public Triple depends(SLExpression lhs, Term rhs, } - public Term assignable(@Nonnull Term term) { + public Term assignable(@NonNull Term term) { return accessible(term); } - public Term accessible(@Nonnull Term ensuresTerm) { + public Term accessible(@NonNull Term ensuresTerm) { BooleanLDT booleanLDT = services.getTypeConverter().getBooleanLDT(); if (ensuresTerm.sort() == booleanLDT.targetSort()) { return tb.convertToFormula(ensuresTerm); @@ -1115,11 +1115,11 @@ public SLExpression createSkolemExprObject(String jmlKeyWord) { * Create a nullary predicate (wrapped in SLExpression) for currently unsupported JML * expressions of type boolean. */ - public @Nonnull SLExpression createSkolemExprBool(@Nonnull Token jmlKeyWord) { + public @NonNull SLExpression createSkolemExprBool(@NonNull Token jmlKeyWord) { return createSkolemExprBool(jmlKeyWord.getText()); } - public @Nonnull SLExpression createSkolemExprBool(String jmlKeyWord) { + public @NonNull SLExpression createSkolemExprBool(String jmlKeyWord) { exc.addUnderspecifiedWarning(jmlKeyWord); final Namespace fns = services.getNamespaces().functions(); final String shortName = jmlKeyWord.replace("\\", ""); @@ -1137,14 +1137,14 @@ public SLExpression createSkolemExprObject(String jmlKeyWord) { /** * Get non-critical warnings. */ - public @Nonnull List getWarnings() { + public @NonNull List getWarnings() { return new ArrayList<>(warnings); } /** * Get non-critical warnings. */ - public @Nonnull String getWarningsAsString() { + public @NonNull String getWarningsAsString() { StringBuilder sb = new StringBuilder(); for (PositionedString s : warnings) { sb.append(s.toString()); @@ -1178,9 +1178,9 @@ public SLExpression skolemExprHelper(String jmlKeyWord, KeYJavaType type, } - @Nonnull - public SLExpression skolemExprHelper(@Nonnull KeYJavaType type, @Nonnull TermServices services, - @Nonnull String shortName) { + @NonNull + public SLExpression skolemExprHelper(@NonNull KeYJavaType type, @NonNull TermServices services, + @NonNull String shortName) { shortName = shortName.replace("\\", ""); final Namespace fns = services.getNamespaces().functions(); final Sort sort = type.getSort(); @@ -1301,9 +1301,9 @@ public SLExpression translateMapExpressionToJDL(String text, ImmutableList qvs) { final Type type = kjt.getJavaType(); final int arrayDepth = JMLSpecExtractor.arrayDepth(type, services); diff --git a/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/LDTHandler.java b/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/LDTHandler.java index aa92cf14387..07cb70f54c7 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/LDTHandler.java +++ b/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/LDTHandler.java @@ -1,7 +1,7 @@ package de.uka.ilkd.key.speclang.njml; import java.util.Map; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.java.abstraction.KeYJavaType; diff --git a/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/LabeledParserRuleContext.java b/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/LabeledParserRuleContext.java index be11cf5d990..bd91d59abb7 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/LabeledParserRuleContext.java +++ b/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/LabeledParserRuleContext.java @@ -1,8 +1,8 @@ package de.uka.ilkd.key.speclang.njml; import java.net.URI; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import org.jspecify.annotations.NonNull; +import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.logic.label.OriginTermLabel; import de.uka.ilkd.key.logic.label.TermLabel; @@ -14,7 +14,7 @@ * This class maps a {@link ParserRuleContext} to a {@link TermLabel}. */ public class LabeledParserRuleContext { - @Nonnull + @NonNull public final ParserRuleContext first; @Nullable public final TermLabel second; diff --git a/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/OverloadedOperatorHandler.java b/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/OverloadedOperatorHandler.java index 59b311f45fb..ea4d68eaaea 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/OverloadedOperatorHandler.java +++ b/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/OverloadedOperatorHandler.java @@ -1,7 +1,7 @@ package de.uka.ilkd.key.speclang.njml; import java.util.*; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.ldt.LocSetLDT; diff --git a/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/PreParser.java b/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/PreParser.java index 67373423e61..afac946ec92 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/PreParser.java +++ b/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/PreParser.java @@ -3,7 +3,7 @@ import java.net.URI; import java.util.ArrayList; import java.util.List; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.java.Position; import de.uka.ilkd.key.parser.Location; @@ -27,7 +27,7 @@ public PreParser() {} * parse tree. */ public ImmutableList parseClassLevel(JmlLexer lexer) { - @Nonnull + @NonNull JmlParser p = JmlFacade.createParser(lexer); JmlParser.Classlevel_commentsContext ctx = p.classlevel_comments(); p.getErrorReporter().throwException(); @@ -68,7 +68,7 @@ public ImmutableList parseMethodLevel(PositionedString posi * parse tree. */ private ImmutableList parseMethodLevel(JmlLexer lexer) { - @Nonnull + @NonNull JmlParser p = JmlFacade.createParser(lexer); JmlParser.Methodlevel_commentContext ctx = p.methodlevel_comment(); p.getErrorReporter().throwException(); diff --git a/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/TextualTranslator.java b/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/TextualTranslator.java index e003ec6fe7f..672f5c877e5 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/TextualTranslator.java +++ b/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/TextualTranslator.java @@ -1,6 +1,6 @@ package de.uka.ilkd.key.speclang.njml; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.ldt.HeapLDT; import de.uka.ilkd.key.logic.Name; diff --git a/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/Translator.java b/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/Translator.java index 2a7288d789a..bdc36a4d898 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/Translator.java +++ b/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/Translator.java @@ -5,8 +5,8 @@ import java.util.Map; import java.util.Optional; import java.util.stream.Collectors; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import org.jspecify.annotations.NonNull; +import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.java.JavaInfo; import de.uka.ilkd.key.java.Label; @@ -916,7 +916,7 @@ public Object visitThis_(JmlParser.This_Context ctx) { return getThisReceiver(); } - @Nonnull + @NonNull private SLExpression getThisReceiver() { return new SLExpression(tb.var(selfVar), selfVar.getKeYJavaType()); } @@ -1599,7 +1599,7 @@ public Object visitPrimaryUnionInf(JmlParser.PrimaryUnionInfContext ctx) { ctx.predicate(), ctx.storeref()); } - @Nonnull + @NonNull private Object createInfiniteUnion(JmlParser.BoundvarmodifiersContext boundvarmodifiers, JmlParser.QuantifiedvardeclsContext quantifiedvardecls, JmlParser.PredicateContext predicate, JmlParser.StorerefContext storeref) { @@ -2034,7 +2034,7 @@ public Pair visitBreaks_clause(JmlParser.Breaks_clauseContext ctx) String label = ctx.lbl == null ? "" : ctx.lbl.getText(); SLExpression pred = accept(ctx.predornot()); assert pred != null; - @Nonnull + @NonNull Pair t = termFactory.createBreaks(pred.getTerm(), label); contractClauses.add(ContractClauses.BREAKS, t.first, t.second); return t; @@ -2045,7 +2045,7 @@ public Pair visitContinues_clause(JmlParser.Continues_clauseContext String label = ctx.lbl == null ? "" : ctx.lbl.getText(); SLExpression pred = accept(ctx.predornot()); assert pred != null; - @Nonnull + @NonNull Pair t = termFactory.createContinues(pred.getTerm(), label); contractClauses.add(ContractClauses.CONTINUES, t.first, t.second); return t; diff --git a/key.core/src/main/java/de/uka/ilkd/key/speclang/translation/JavaIntegerSemanticsHelper.java b/key.core/src/main/java/de/uka/ilkd/key/speclang/translation/JavaIntegerSemanticsHelper.java index e6767a69679..ff5c0e4354b 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/speclang/translation/JavaIntegerSemanticsHelper.java +++ b/key.core/src/main/java/de/uka/ilkd/key/speclang/translation/JavaIntegerSemanticsHelper.java @@ -8,7 +8,7 @@ // import de.uka.ilkd.key.logic.Term; // import de.uka.ilkd.key.logic.TermBuilder; // import de.uka.ilkd.key.logic.op.Function; -// import javax.annotation.Nonnull; +// import org.jspecify.annotations.NonNull; // // /// ** @@ -82,13 +82,13 @@ // //public interface // //------------------------------------------------------------------------- // -// public boolean isIntegerTerm(@Nonnull SLExpression a) { +// public boolean isIntegerTerm(@NonNull SLExpression a) { // assert a.isTerm(); // return a.getTerm().sort() == integerLDT.targetSort(); // } // // -// public SLExpression buildPromotedOrExpression(@Nonnull SLExpression a, @Nonnull SLExpression b) +// public SLExpression buildPromotedOrExpression(@NonNull SLExpression a, @NonNull SLExpression b) // throws SLTranslationException { // assert a != null; // assert b != null; diff --git a/key.core/src/main/java/de/uka/ilkd/key/speclang/translation/SLExceptionFactory.java b/key.core/src/main/java/de/uka/ilkd/key/speclang/translation/SLExceptionFactory.java index f1b949564ff..a153a577383 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/speclang/translation/SLExceptionFactory.java +++ b/key.core/src/main/java/de/uka/ilkd/key/speclang/translation/SLExceptionFactory.java @@ -3,7 +3,7 @@ import java.net.URI; import java.util.LinkedList; import java.util.List; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.java.Position; import de.uka.ilkd.key.parser.Location; @@ -44,7 +44,7 @@ public class SLExceptionFactory { // constructors // ------------------------------------------------------------------------- - public SLExceptionFactory(@Nonnull Parser parser, URI fileName, Position offsetPos) { + public SLExceptionFactory(@NonNull Parser parser, URI fileName, Position offsetPos) { this.line = parser.getInputStream().LT(1).getLine(); this.column = parser.getInputStream().LT(1).getCharPositionInLine(); this.fileName = fileName; diff --git a/key.core/src/main/java/de/uka/ilkd/key/speclang/translation/SLExpression.java b/key.core/src/main/java/de/uka/ilkd/key/speclang/translation/SLExpression.java index 8d227b9468b..5dee431fe46 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/speclang/translation/SLExpression.java +++ b/key.core/src/main/java/de/uka/ilkd/key/speclang/translation/SLExpression.java @@ -1,6 +1,6 @@ package de.uka.ilkd.key.speclang.translation; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.java.abstraction.KeYJavaType; import de.uka.ilkd.key.logic.Term; @@ -16,7 +16,7 @@ public final class SLExpression { private final boolean isTerm; - public SLExpression(@Nonnull Term term, @Nonnull KeYJavaType type, boolean isTerm) { + public SLExpression(@NonNull Term term, @NonNull KeYJavaType type, boolean isTerm) { if (term.sort() != Sort.ANY && term.sort() != type.getSort()) { throw new IllegalArgumentException( String.format("term has sort: %s; type has sort: %s", term.sort(), type.getSort())); @@ -26,7 +26,7 @@ public SLExpression(@Nonnull Term term, @Nonnull KeYJavaType type, boolean isTer this.isTerm = isTerm; } - public SLExpression(@Nonnull Term term, @Nonnull KeYJavaType type) { + public SLExpression(@NonNull Term term, @NonNull KeYJavaType type) { this(term, type, true); } @@ -34,14 +34,14 @@ public SLExpression(@Nonnull Term term, @Nonnull KeYJavaType type) { /** * USE WITH CARE! Term-SLExpressions should have a type! */ - public SLExpression(@Nonnull Term term) { + public SLExpression(@NonNull Term term) { this.term = term; this.type = null; this.isTerm = true; } - public SLExpression(@Nonnull KeYJavaType type) { + public SLExpression(@NonNull KeYJavaType type) { this.term = null; this.type = type; this.isTerm = false; diff --git a/key.core/src/main/java/de/uka/ilkd/key/speclang/translation/SLTranslationException.java b/key.core/src/main/java/de/uka/ilkd/key/speclang/translation/SLTranslationException.java index 775bf98f71c..285b1096a68 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/speclang/translation/SLTranslationException.java +++ b/key.core/src/main/java/de/uka/ilkd/key/speclang/translation/SLTranslationException.java @@ -2,7 +2,7 @@ import java.net.MalformedURLException; import java.net.URI; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.java.Position; import de.uka.ilkd.key.parser.Location; diff --git a/key.core/src/main/java/de/uka/ilkd/key/strategy/NumberRuleAppCost.java b/key.core/src/main/java/de/uka/ilkd/key/strategy/NumberRuleAppCost.java index 63cf726345f..37d3b50eba8 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/strategy/NumberRuleAppCost.java +++ b/key.core/src/main/java/de/uka/ilkd/key/strategy/NumberRuleAppCost.java @@ -1,6 +1,6 @@ package de.uka.ilkd.key.strategy; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.util.Debug; @@ -53,9 +53,9 @@ public static RuleAppCost create(long p_cost) { */ public abstract long getValue(); - @Nonnull + @NonNull @Override - public RuleAppCost mul(@Nonnull RuleAppCost cost) { + public RuleAppCost mul(@NonNull RuleAppCost cost) { if (cost instanceof TopRuleAppCost) { return cost.mul(this); } diff --git a/key.core/src/main/java/de/uka/ilkd/key/strategy/QueueRuleApplicationManager.java b/key.core/src/main/java/de/uka/ilkd/key/strategy/QueueRuleApplicationManager.java index 509550c7792..2f7a31db077 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/strategy/QueueRuleApplicationManager.java +++ b/key.core/src/main/java/de/uka/ilkd/key/strategy/QueueRuleApplicationManager.java @@ -3,7 +3,7 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.concurrent.atomic.AtomicLong; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.logic.PosInOccurrence; import de.uka.ilkd.key.proof.Goal; diff --git a/key.core/src/main/java/de/uka/ilkd/key/strategy/RuleAppCost.java b/key.core/src/main/java/de/uka/ilkd/key/strategy/RuleAppCost.java index d6e56b0d8c3..f86542bff90 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/strategy/RuleAppCost.java +++ b/key.core/src/main/java/de/uka/ilkd/key/strategy/RuleAppCost.java @@ -1,6 +1,6 @@ package de.uka.ilkd.key.strategy; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; /** * Represents the costs of a rule. In the default case this is just an integral number, but in some @@ -10,13 +10,13 @@ */ public interface RuleAppCost extends Comparable { - int compareTo(@Nonnull RuleAppCost o); + int compareTo(@NonNull RuleAppCost o); /** * Add the given costs to the costs that are represented by this object */ - @Nonnull - RuleAppCost add(@Nonnull RuleAppCost cost2); + @NonNull + RuleAppCost add(@NonNull RuleAppCost cost2); /** @@ -28,6 +28,6 @@ public interface RuleAppCost extends Comparable { * * @param cost - non-null {@link RuleAppCost} */ - @Nonnull - RuleAppCost mul(@Nonnull RuleAppCost cost); + @NonNull + RuleAppCost mul(@NonNull RuleAppCost cost); } diff --git a/key.core/src/main/java/de/uka/ilkd/key/strategy/TopRuleAppCost.java b/key.core/src/main/java/de/uka/ilkd/key/strategy/TopRuleAppCost.java index 5f2c219aacd..319090aadd0 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/strategy/TopRuleAppCost.java +++ b/key.core/src/main/java/de/uka/ilkd/key/strategy/TopRuleAppCost.java @@ -1,6 +1,6 @@ package de.uka.ilkd.key.strategy; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; /** * Singleton implementation of the RuleAppCost interface, which denotes a maximum cost @@ -10,7 +10,7 @@ public class TopRuleAppCost implements RuleAppCost { private TopRuleAppCost() {} - public int compareTo(@Nonnull RuleAppCost o) { + public int compareTo(@NonNull RuleAppCost o) { if (o instanceof TopRuleAppCost) { return 0; } @@ -34,7 +34,7 @@ public int hashCode() { * @param cost2 the other costs * @return this instance */ - public final RuleAppCost add(@Nonnull RuleAppCost cost2) { + public final RuleAppCost add(@NonNull RuleAppCost cost2) { return INSTANCE; } @@ -46,9 +46,9 @@ public final RuleAppCost add(@Nonnull RuleAppCost cost2) { * @param cost - non-null {@link RuleAppCost} * @return this instance */ - @Nonnull + @NonNull @Override - public RuleAppCost mul(@Nonnull RuleAppCost cost) { + public RuleAppCost mul(@NonNull RuleAppCost cost) { return this; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/strategy/feature/AppliedRuleAppsNameCache.java b/key.core/src/main/java/de/uka/ilkd/key/strategy/feature/AppliedRuleAppsNameCache.java index d63e293394a..cf7e2bae76c 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/strategy/feature/AppliedRuleAppsNameCache.java +++ b/key.core/src/main/java/de/uka/ilkd/key/strategy/feature/AppliedRuleAppsNameCache.java @@ -2,7 +2,7 @@ import java.util.*; import java.util.concurrent.locks.ReentrantReadWriteLock; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.logic.Name; import de.uka.ilkd.key.proof.Node; @@ -33,7 +33,7 @@ public AppliedRuleAppsNameCache() {} * @param node the node * @return the value */ - private @Nonnull HashMap> fillCacheForNode(Node node) { + private @NonNull HashMap> fillCacheForNode(Node node) { HashMap> nodeCache; try { writeLock.lock(); @@ -103,7 +103,7 @@ public AppliedRuleAppsNameCache() {} * @param name the name * @return rule apps */ - public @Nonnull List get(@Nonnull Node node, @Nonnull Name name) { + public @NonNull List get(@NonNull Node node, @NonNull Name name) { if (node.getAppliedRuleApp() != null || node.childrenCount() != 0) { throw new AssertionFailure("Expected an empty leaf node"); } diff --git a/key.core/src/main/java/de/uka/ilkd/key/taclettranslation/lemma/TacletProofObligationInput.java b/key.core/src/main/java/de/uka/ilkd/key/taclettranslation/lemma/TacletProofObligationInput.java index 1ffbce9c7c4..bdd155020f8 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/taclettranslation/lemma/TacletProofObligationInput.java +++ b/key.core/src/main/java/de/uka/ilkd/key/taclettranslation/lemma/TacletProofObligationInput.java @@ -3,7 +3,7 @@ import java.io.File; import java.io.IOException; import java.util.*; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.java.abstraction.KeYJavaType; import de.uka.ilkd.key.logic.Name; diff --git a/key.core/src/main/java/de/uka/ilkd/key/taclettranslation/lemma/TacletSoundnessPOLoader.java b/key.core/src/main/java/de/uka/ilkd/key/taclettranslation/lemma/TacletSoundnessPOLoader.java index 20dcc927e22..01beae9937f 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/taclettranslation/lemma/TacletSoundnessPOLoader.java +++ b/key.core/src/main/java/de/uka/ilkd/key/taclettranslation/lemma/TacletSoundnessPOLoader.java @@ -1,7 +1,7 @@ package de.uka.ilkd.key.taclettranslation.lemma; import java.util.*; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.proof.CompoundProof; import de.uka.ilkd.key.proof.Proof; diff --git a/key.core/src/main/java/de/uka/ilkd/key/util/ExceptionTools.java b/key.core/src/main/java/de/uka/ilkd/key/util/ExceptionTools.java index 313b4a360d0..67320ca832d 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/util/ExceptionTools.java +++ b/key.core/src/main/java/de/uka/ilkd/key/util/ExceptionTools.java @@ -4,8 +4,8 @@ import java.util.Optional; import java.util.regex.Matcher; import java.util.regex.Pattern; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import org.jspecify.annotations.NonNull; +import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.java.Position; import de.uka.ilkd.key.parser.Location; @@ -44,7 +44,7 @@ private ExceptionTools() { * given Throwable can not be successfully converted to a URL and thus no Location can * be created */ - public static Optional getLocation(@Nonnull Throwable exc) + public static Optional getLocation(@NonNull Throwable exc) throws MalformedURLException { if (exc instanceof HasLocation) { return Optional.ofNullable(((HasLocation) exc).getLocation()); diff --git a/key.core/src/main/java/de/uka/ilkd/key/util/MiscTools.java b/key.core/src/main/java/de/uka/ilkd/key/util/MiscTools.java index 52a11e69a1d..5213f31ecb4 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/util/MiscTools.java +++ b/key.core/src/main/java/de/uka/ilkd/key/util/MiscTools.java @@ -13,7 +13,7 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.zip.ZipFile; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.java.*; import de.uka.ilkd.key.java.declaration.VariableSpecification; diff --git a/key.core/src/main/java/de/uka/ilkd/key/util/RecognitionException.java b/key.core/src/main/java/de/uka/ilkd/key/util/RecognitionException.java index 236979f78dd..ecbf34d7f34 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/util/RecognitionException.java +++ b/key.core/src/main/java/de/uka/ilkd/key/util/RecognitionException.java @@ -1,7 +1,7 @@ package de.uka.ilkd.key.util; import java.net.MalformedURLException; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.java.Position; import de.uka.ilkd.key.parser.Location; diff --git a/key.core/src/main/java/de/uka/ilkd/key/util/mergerule/MergeRuleUtils.java b/key.core/src/main/java/de/uka/ilkd/key/util/mergerule/MergeRuleUtils.java index 2e6243d0778..0ca1207f003 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/util/mergerule/MergeRuleUtils.java +++ b/key.core/src/main/java/de/uka/ilkd/key/util/mergerule/MergeRuleUtils.java @@ -3,7 +3,7 @@ import java.io.StringReader; import java.util.*; import java.util.stream.Collectors; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.axiom_abstraction.predicateabstraction.AbstractionPredicate; import de.uka.ilkd.key.java.*; @@ -135,7 +135,7 @@ public static ArrayList singletonArrayList(T elem) { */ public static Term translateToFormula(final Services services, final String toTranslate) { try { - @Nonnull + @NonNull Term result = new KeyIO(services).parseExpression(toTranslate); return result.sort() == Sort.FORMULA ? result : null; } catch (Throwable e) { diff --git a/key.core/src/main/java/de/uka/ilkd/key/util/parsing/BuildingException.java b/key.core/src/main/java/de/uka/ilkd/key/util/parsing/BuildingException.java index 233109578af..6075a654b3d 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/util/parsing/BuildingException.java +++ b/key.core/src/main/java/de/uka/ilkd/key/util/parsing/BuildingException.java @@ -2,7 +2,7 @@ import java.net.MalformedURLException; import java.net.URI; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.java.Position; import de.uka.ilkd.key.parser.Location; diff --git a/key.core/src/main/java/de/uka/ilkd/key/util/parsing/BuildingIssue.java b/key.core/src/main/java/de/uka/ilkd/key/util/parsing/BuildingIssue.java index f30d8133bf5..66963b62e5a 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/util/parsing/BuildingIssue.java +++ b/key.core/src/main/java/de/uka/ilkd/key/util/parsing/BuildingIssue.java @@ -1,6 +1,6 @@ package de.uka.ilkd.key.util.parsing; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.java.Position; diff --git a/key.core/src/main/java/de/uka/ilkd/key/util/parsing/HasLocation.java b/key.core/src/main/java/de/uka/ilkd/key/util/parsing/HasLocation.java index 02029101e9b..f8aabe6091d 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/util/parsing/HasLocation.java +++ b/key.core/src/main/java/de/uka/ilkd/key/util/parsing/HasLocation.java @@ -1,7 +1,7 @@ package de.uka.ilkd.key.util.parsing; import java.net.MalformedURLException; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.parser.Location; diff --git a/key.core/src/main/java/de/uka/ilkd/key/util/parsing/LocatableException.java b/key.core/src/main/java/de/uka/ilkd/key/util/parsing/LocatableException.java index ff622a48d64..c3654a656ed 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/util/parsing/LocatableException.java +++ b/key.core/src/main/java/de/uka/ilkd/key/util/parsing/LocatableException.java @@ -1,7 +1,7 @@ package de.uka.ilkd.key.util.parsing; import java.net.MalformedURLException; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.parser.Location; diff --git a/key.core/src/main/java/de/uka/ilkd/key/util/parsing/SyntaxErrorReporter.java b/key.core/src/main/java/de/uka/ilkd/key/util/parsing/SyntaxErrorReporter.java index a5251d38217..4090f6b6d55 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/util/parsing/SyntaxErrorReporter.java +++ b/key.core/src/main/java/de/uka/ilkd/key/util/parsing/SyntaxErrorReporter.java @@ -7,7 +7,7 @@ import java.util.List; import java.util.function.Supplier; import java.util.stream.Collectors; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.java.Position; import de.uka.ilkd.key.parser.Location; diff --git a/key.core/src/main/java/de/uka/ilkd/key/util/pp/Layouter.java b/key.core/src/main/java/de/uka/ilkd/key/util/pp/Layouter.java index 4bf8ad45ffd..014cef97c34 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/util/pp/Layouter.java +++ b/key.core/src/main/java/de/uka/ilkd/key/util/pp/Layouter.java @@ -1,7 +1,7 @@ package de.uka.ilkd.key.util.pp; import java.util.*; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; /** * This class pretty-prints information using line breaks and indentation. For instance, it can be @@ -595,7 +595,7 @@ private StreamToken pop() { /** * Remove and return the token from the bottom of the delimStack */ - private @Nonnull StreamToken popBottom() { + private @NonNull StreamToken popBottom() { StreamToken token = delimStack.pollFirst(); if (token == null) { throw new UnbalancedBlocksException(); diff --git a/key.core/src/test/java/de/uka/ilkd/key/nparser/TestTacletEquality.java b/key.core/src/test/java/de/uka/ilkd/key/nparser/TestTacletEquality.java index 27b8b473976..e56875f2ecf 100644 --- a/key.core/src/test/java/de/uka/ilkd/key/nparser/TestTacletEquality.java +++ b/key.core/src/test/java/de/uka/ilkd/key/nparser/TestTacletEquality.java @@ -9,7 +9,7 @@ import java.util.Date; import java.util.HashMap; import java.util.stream.Stream; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.control.DefaultUserInterfaceControl; import de.uka.ilkd.key.proof.init.InitConfig; @@ -137,7 +137,7 @@ private void assertEquals(String expected, String actual) { Assertions.assertEquals(normalise(expected).trim(), normalise(actual).trim()); } - @Nonnull + @NonNull private String normalise(String expected) { return expected.replaceAll("\\s+", "\n").replaceAll("Choices:\\s*\\{.*?\\}", ""); } diff --git a/key.core/src/test/java/de/uka/ilkd/key/parser/TestTermParserHeap.java b/key.core/src/test/java/de/uka/ilkd/key/parser/TestTermParserHeap.java index ac0be805c3d..8ad8c985fef 100644 --- a/key.core/src/test/java/de/uka/ilkd/key/parser/TestTermParserHeap.java +++ b/key.core/src/test/java/de/uka/ilkd/key/parser/TestTermParserHeap.java @@ -1,7 +1,7 @@ package de.uka.ilkd.key.parser; import java.io.IOException; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.logic.Term; import de.uka.ilkd.key.logic.op.Operator; @@ -198,7 +198,7 @@ public void testBugResettingCounter() throws Exception { @Test public void testVerifyExceptionIfAtOperatorNotPreceededBySelectTerm() { try { - @Nonnull + @NonNull Term t = io.parseExpression("(a.f + a.f)@h2"); LOGGER.info("Out: {}", t); fail(); diff --git a/key.core/src/test/java/de/uka/ilkd/key/rule/merge/MergeRuleTests.java b/key.core/src/test/java/de/uka/ilkd/key/rule/merge/MergeRuleTests.java index 1b1c9a8ac3b..714c95c40e4 100644 --- a/key.core/src/test/java/de/uka/ilkd/key/rule/merge/MergeRuleTests.java +++ b/key.core/src/test/java/de/uka/ilkd/key/rule/merge/MergeRuleTests.java @@ -2,7 +2,7 @@ import java.io.File; import java.util.Iterator; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.control.KeYEnvironment; import de.uka.ilkd.key.java.Services; @@ -309,7 +309,7 @@ public static Proof loadProof(String directory, String proofFileName) { * @param proofFileName The file name of the proof file to load. * @return The loaded proof. */ - @Nonnull + @NonNull public static Proof loadProof(File directory, String proofFileName) { File proofFile = new File(directory, proofFileName); assertTrue(proofFile.exists(), diff --git a/key.core/src/test/java/de/uka/ilkd/key/smt/newsmt2/MasterHandlerTest.java b/key.core/src/test/java/de/uka/ilkd/key/smt/newsmt2/MasterHandlerTest.java index c82ff434aae..9c487746fa5 100644 --- a/key.core/src/test/java/de/uka/ilkd/key/smt/newsmt2/MasterHandlerTest.java +++ b/key.core/src/test/java/de/uka/ilkd/key/smt/newsmt2/MasterHandlerTest.java @@ -15,7 +15,7 @@ import java.util.List; import java.util.Properties; import java.util.stream.Collectors; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.control.DefaultUserInterfaceControl; import de.uka.ilkd.key.control.KeYEnvironment; diff --git a/key.ui/src/main/java/de/uka/ilkd/key/core/KeYMediator.java b/key.ui/src/main/java/de/uka/ilkd/key/core/KeYMediator.java index 108374cae5d..c460fc20f6f 100644 --- a/key.ui/src/main/java/de/uka/ilkd/key/core/KeYMediator.java +++ b/key.ui/src/main/java/de/uka/ilkd/key/core/KeYMediator.java @@ -4,8 +4,8 @@ import java.util.Collection; import java.util.EventObject; import java.util.function.Consumer; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import org.jspecify.annotations.NonNull; +import org.jspecify.annotations.Nullable; import javax.swing.*; import javax.swing.event.EventListenerList; @@ -687,7 +687,7 @@ public void deregister(T obj, Class service) { * * @return */ - public @Nonnull Lookup getUserData() { + public @NonNull Lookup getUserData() { if (userData == null) { userData = new Lookup(); } @@ -976,7 +976,7 @@ public AutoSaver getAutoSaver() { * * @see DefaultListModel#addListDataListener */ - public @Nonnull DefaultListModel getCurrentlyOpenedProofs() { + public @NonNull DefaultListModel getCurrentlyOpenedProofs() { return currentlyOpenedProofs; } diff --git a/key.ui/src/main/java/de/uka/ilkd/key/core/Log.java b/key.ui/src/main/java/de/uka/ilkd/key/core/Log.java index 39783863441..6bcc69741cf 100644 --- a/key.ui/src/main/java/de/uka/ilkd/key/core/Log.java +++ b/key.ui/src/main/java/de/uka/ilkd/key/core/Log.java @@ -8,7 +8,7 @@ import java.time.Duration; import java.time.Instant; import java.time.temporal.ChronoUnit; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.settings.PathConfig; import de.uka.ilkd.key.ui.Verbosity; diff --git a/key.ui/src/main/java/de/uka/ilkd/key/gui/KeYFileChooserBookmarkPanel.java b/key.ui/src/main/java/de/uka/ilkd/key/gui/KeYFileChooserBookmarkPanel.java index 5a437db3754..967f0dd40ac 100644 --- a/key.ui/src/main/java/de/uka/ilkd/key/gui/KeYFileChooserBookmarkPanel.java +++ b/key.ui/src/main/java/de/uka/ilkd/key/gui/KeYFileChooserBookmarkPanel.java @@ -6,7 +6,7 @@ import java.util.ArrayList; import java.util.Enumeration; import java.util.List; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; import javax.swing.*; import javax.swing.filechooser.FileFilter; @@ -30,7 +30,7 @@ public class KeYFileChooserBookmarkPanel extends JPanel { private static final long serialVersionUID = -6498548666886815605L; - private final @Nonnull JFileChooser chooser; + private final @NonNull JFileChooser chooser; private final ViewSettings viewSettings = ProofIndependentSettings.DEFAULT_INSTANCE.getViewSettings(); @@ -48,7 +48,7 @@ public class KeYFileChooserBookmarkPanel extends JPanel { * * @param chooser non null {@link JFileChooser} */ - public KeYFileChooserBookmarkPanel(@Nonnull JFileChooser chooser) { + public KeYFileChooserBookmarkPanel(@NonNull JFileChooser chooser) { this.chooser = chooser; // register ad the given file chooser chooser.setAccessory(this); diff --git a/key.ui/src/main/java/de/uka/ilkd/key/gui/KeyboardTacletExtension.java b/key.ui/src/main/java/de/uka/ilkd/key/gui/KeyboardTacletExtension.java index 4722b81591b..550c8d2a73b 100644 --- a/key.ui/src/main/java/de/uka/ilkd/key/gui/KeyboardTacletExtension.java +++ b/key.ui/src/main/java/de/uka/ilkd/key/gui/KeyboardTacletExtension.java @@ -7,8 +7,8 @@ import java.util.*; import java.util.List; import java.util.stream.Collectors; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import org.jspecify.annotations.NonNull; +import org.jspecify.annotations.Nullable; import javax.swing.*; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; @@ -55,10 +55,10 @@ public class KeyboardTacletExtension implements KeYGuiExtension, KeYGuiExtension.LeftPanel { private KeyboardTacletPanel panel; - @Nonnull + @NonNull @Override - public Collection getPanels(@Nonnull MainWindow window, - @Nonnull KeYMediator mediator) { + public Collection getPanels(@NonNull MainWindow window, + @NonNull KeYMediator mediator) { mediator.addKeYSelectionListener(new KeYSelectionListener() { @Override public void selectedNodeChanged(KeYSelectionEvent e) { diff --git a/key.ui/src/main/java/de/uka/ilkd/key/gui/MainWindow.java b/key.ui/src/main/java/de/uka/ilkd/key/gui/MainWindow.java index ae6f364eb25..afc77a62a95 100644 --- a/key.ui/src/main/java/de/uka/ilkd/key/gui/MainWindow.java +++ b/key.ui/src/main/java/de/uka/ilkd/key/gui/MainWindow.java @@ -17,7 +17,7 @@ import java.util.prefs.BackingStoreException; import java.util.prefs.Preferences; import java.util.stream.Stream; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; import javax.swing.*; import javax.swing.event.ChangeListener; import javax.swing.event.MenuEvent; @@ -1351,7 +1351,7 @@ public NotificationManager getNotificationManager() { * * @see RecentFileMenu#addRecentFile(String) */ - public void addRecentFile(@Nonnull String absolutePath) { + public void addRecentFile(@NonNull String absolutePath) { recentFileMenu.addRecentFile(absolutePath); } diff --git a/key.ui/src/main/java/de/uka/ilkd/key/gui/PositionedIssueString.java b/key.ui/src/main/java/de/uka/ilkd/key/gui/PositionedIssueString.java index 742d0b94b1d..3468b450c25 100644 --- a/key.ui/src/main/java/de/uka/ilkd/key/gui/PositionedIssueString.java +++ b/key.ui/src/main/java/de/uka/ilkd/key/gui/PositionedIssueString.java @@ -1,7 +1,7 @@ package de.uka.ilkd.key.gui; import java.util.Objects; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.java.Position; import de.uka.ilkd.key.parser.Location; @@ -22,27 +22,27 @@ public enum Kind { /** * contains additional information, e.g., a stacktrace */ - private final @Nonnull String additionalInfo; + private final @NonNull String additionalInfo; private final Kind kind; - public PositionedIssueString(@Nonnull String text, @Nonnull Location location, - @Nonnull String additionalInfo) { + public PositionedIssueString(@NonNull String text, @NonNull Location location, + @NonNull String additionalInfo) { this(text, location, additionalInfo, Kind.ERROR); } - public PositionedIssueString(@Nonnull String text, @Nonnull Location location, - @Nonnull String additionalInfo, Kind kind) { + public PositionedIssueString(@NonNull String text, @NonNull Location location, + @NonNull String additionalInfo, Kind kind) { super(text, location); this.additionalInfo = additionalInfo; this.kind = kind; } - public PositionedIssueString(@Nonnull String text) { + public PositionedIssueString(@NonNull String text) { this(text, new Location(null, Position.UNDEFINED), "", Kind.ERROR); } - public PositionedIssueString(@Nonnull PositionedString o, @Nonnull String additionalInfo) { + public PositionedIssueString(@NonNull PositionedString o, @NonNull String additionalInfo) { this(o.text, o.location, additionalInfo, Kind.ERROR); } @@ -50,7 +50,7 @@ public Kind getKind() { return kind; } - @Nonnull + @NonNull public String getAdditionalInfo() { return additionalInfo; } diff --git a/key.ui/src/main/java/de/uka/ilkd/key/gui/ProofManagementDialog.java b/key.ui/src/main/java/de/uka/ilkd/key/gui/ProofManagementDialog.java index 157623efb36..efc67f65664 100644 --- a/key.ui/src/main/java/de/uka/ilkd/key/gui/ProofManagementDialog.java +++ b/key.ui/src/main/java/de/uka/ilkd/key/gui/ProofManagementDialog.java @@ -12,8 +12,8 @@ import java.util.Set; import java.util.stream.Collectors; import java.util.stream.Stream; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import org.jspecify.annotations.NonNull; +import org.jspecify.annotations.Nullable; import javax.swing.*; import javax.swing.border.TitledBorder; @@ -364,7 +364,7 @@ private static boolean showInstance(InitConfig initConfig, KeYJavaType selectedK /** * Selects the contract by the given {@link ContractId} */ - private void select(@Nonnull ContractId cid) { + private void select(@NonNull ContractId cid) { Services servicesLocal = initConfig.getServices(); String keyJavaTypeName = cid.keyJavaTypeName; Optional allJavaTypes = @@ -432,7 +432,7 @@ private Contract getSelectedContract() { * lemmas and then just any proof or {@code null} if there is no proof for the contract */ @Nullable - private Proof findPreferablyClosedProof(@Nonnull Contract contract) { + private Proof findPreferablyClosedProof(@NonNull Contract contract) { // will the contracts here always be atomic? // it seems that way, but not completely sure ImmutableSet proofs = @@ -454,7 +454,7 @@ private Proof findPreferablyClosedProof(@Nonnull Contract contract) { return fallback; } - private void findOrStartProof(@Nonnull Contract contract) { + private void findOrStartProof(@NonNull Contract contract) { Proof proof = findPreferablyClosedProof(contract); if (proof == null) { AbstractMediatorUserInterfaceControl ui = mediator.getUI(); diff --git a/key.ui/src/main/java/de/uka/ilkd/key/gui/SearchBar.java b/key.ui/src/main/java/de/uka/ilkd/key/gui/SearchBar.java index 282c44f937d..899b9b119fc 100644 --- a/key.ui/src/main/java/de/uka/ilkd/key/gui/SearchBar.java +++ b/key.ui/src/main/java/de/uka/ilkd/key/gui/SearchBar.java @@ -2,7 +2,7 @@ import java.awt.*; import java.awt.event.KeyEvent; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; import javax.swing.*; import javax.swing.border.Border; import javax.swing.border.CompoundBorder; @@ -109,7 +109,7 @@ public void setVisible(boolean vis) { /* * The boolean return value of this function indicates, whether search was successful or not. */ - public abstract boolean search(@Nonnull String s); + public abstract boolean search(@NonNull String s); public void search() { boolean match = search(searchField.getText()); diff --git a/key.ui/src/main/java/de/uka/ilkd/key/gui/actions/EditSourceFileAction.java b/key.ui/src/main/java/de/uka/ilkd/key/gui/actions/EditSourceFileAction.java index f3165dba7bc..ac90b7d6c6a 100644 --- a/key.ui/src/main/java/de/uka/ilkd/key/gui/actions/EditSourceFileAction.java +++ b/key.ui/src/main/java/de/uka/ilkd/key/gui/actions/EditSourceFileAction.java @@ -14,7 +14,7 @@ import java.util.Optional; import java.util.Timer; import java.util.TimerTask; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; import javax.swing.*; import javax.swing.border.TitledBorder; import javax.swing.text.BadLocationException; diff --git a/key.ui/src/main/java/de/uka/ilkd/key/gui/actions/LemmaGenerationAction.java b/key.ui/src/main/java/de/uka/ilkd/key/gui/actions/LemmaGenerationAction.java index 42ee7069843..d11aa0ec08b 100644 --- a/key.ui/src/main/java/de/uka/ilkd/key/gui/actions/LemmaGenerationAction.java +++ b/key.ui/src/main/java/de/uka/ilkd/key/gui/actions/LemmaGenerationAction.java @@ -3,7 +3,7 @@ import java.awt.event.ActionEvent; import java.io.File; import java.util.List; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; import javax.swing.*; import de.uka.ilkd.key.gui.IssueDialog; diff --git a/key.ui/src/main/java/de/uka/ilkd/key/gui/actions/RunAllProofsAction.java b/key.ui/src/main/java/de/uka/ilkd/key/gui/actions/RunAllProofsAction.java index a1e97257bcf..64bf3b76456 100644 --- a/key.ui/src/main/java/de/uka/ilkd/key/gui/actions/RunAllProofsAction.java +++ b/key.ui/src/main/java/de/uka/ilkd/key/gui/actions/RunAllProofsAction.java @@ -7,8 +7,8 @@ import java.util.Collections; import java.util.List; import java.util.stream.Collectors; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import org.jspecify.annotations.NonNull; +import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.core.KeYMediator; import de.uka.ilkd.key.core.Main; @@ -67,7 +67,7 @@ public class RunAllProofsAction extends MainWindowAction { * content of {@link #ENV_VARIABLE} ({@link #RUN_ALL_PROOFS_UI}) is null, then * {@link #DEFAULT_FILE} is used. */ - @Nonnull + @NonNull private List loadFiles() throws IOException { LOGGER.info("Use 'export {}=<...>' to set the input file for {}.", ENV_VARIABLE, getClass().getSimpleName()); diff --git a/key.ui/src/main/java/de/uka/ilkd/key/gui/docking/DockingHelper.java b/key.ui/src/main/java/de/uka/ilkd/key/gui/docking/DockingHelper.java index e857f609ec4..1c5c7e4c109 100644 --- a/key.ui/src/main/java/de/uka/ilkd/key/gui/docking/DockingHelper.java +++ b/key.ui/src/main/java/de/uka/ilkd/key/gui/docking/DockingHelper.java @@ -3,7 +3,7 @@ import java.util.LinkedList; import java.util.List; import java.util.stream.Stream; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; import javax.swing.Action; import javax.swing.Icon; import javax.swing.JComponent; @@ -181,7 +181,7 @@ public static SingleCDockable createSingleDock(TabPanel p) { p.getComponent(), p.getPermissions(), a); } - public static @Nonnull CAction translateAction(@Nonnull Action action) { + public static @NonNull CAction translateAction(@NonNull Action action) { if (action.getValue(Action.SELECTED_KEY) != null) { return createCheckBox(action); @@ -191,7 +191,7 @@ public static SingleCDockable createSingleDock(TabPanel p) { } public static void deriveBaseProperties( - CDecorateableAction derive, @Nonnull Action action) { + CDecorateableAction derive, @NonNull Action action) { derive.setTooltip((String) action.getValue(Action.SHORT_DESCRIPTION)); derive.setEnabled(action.isEnabled()); @@ -203,7 +203,7 @@ public static void deriveBaseProperties( }); } - private static @Nonnull CAction createCheckBox(@Nonnull Action action) { + private static @NonNull CAction createCheckBox(@NonNull Action action) { CCheckBox button = new CCheckBox((String) action.getValue(Action.NAME), (Icon) action.getValue(Action.SMALL_ICON)) { @Override diff --git a/key.ui/src/main/java/de/uka/ilkd/key/gui/docking/DockingLayout.java b/key.ui/src/main/java/de/uka/ilkd/key/gui/docking/DockingLayout.java index f89ec376e0d..668974546d9 100644 --- a/key.ui/src/main/java/de/uka/ilkd/key/gui/docking/DockingLayout.java +++ b/key.ui/src/main/java/de/uka/ilkd/key/gui/docking/DockingLayout.java @@ -8,7 +8,7 @@ import java.io.IOException; import java.util.*; import java.util.List; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; import javax.swing.*; import de.uka.ilkd.key.core.KeYMediator; @@ -127,9 +127,9 @@ private void setLayout(String layout) { DockingHelper.restoreMissingPanels(window); } - @Nonnull + @NonNull @Override - public List getMainMenuActions(@Nonnull MainWindow mainWindow) { + public List getMainMenuActions(@NonNull MainWindow mainWindow) { List actions = new ArrayList<>(); int keypos = 0; for (String layout : LAYOUT_NAMES) { diff --git a/key.ui/src/main/java/de/uka/ilkd/key/gui/extension/api/KeYGuiExtension.java b/key.ui/src/main/java/de/uka/ilkd/key/gui/extension/api/KeYGuiExtension.java index 19c35579179..e5fcc304966 100644 --- a/key.ui/src/main/java/de/uka/ilkd/key/gui/extension/api/KeYGuiExtension.java +++ b/key.ui/src/main/java/de/uka/ilkd/key/gui/extension/api/KeYGuiExtension.java @@ -4,7 +4,7 @@ import java.lang.annotation.RetentionPolicy; import java.util.Collection; import java.util.List; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; import javax.swing.Action; import javax.swing.JComponent; import javax.swing.JMenu; @@ -98,8 +98,8 @@ interface MainMenu { * @return non-null, emptiable list of actions. * @see de.uka.ilkd.key.gui.actions.KeyAction */ - @Nonnull - List getMainMenuActions(@Nonnull MainWindow mainWindow); + @NonNull + List getMainMenuActions(@NonNull MainWindow mainWindow); } /** @@ -125,8 +125,8 @@ interface LeftPanel { * @param window parent of this extension * @param mediator the current mediator */ - @Nonnull - Collection getPanels(@Nonnull MainWindow window, @Nonnull KeYMediator mediator); + @NonNull + Collection getPanels(@NonNull MainWindow window, @NonNull KeYMediator mediator); } /** @@ -149,9 +149,9 @@ interface ContextMenu { * @return non-null, emptiable list of actions. * @see de.uka.ilkd.key.gui.actions.KeyAction */ - @Nonnull - List getContextActions(@Nonnull KeYMediator mediator, @Nonnull ContextMenuKind kind, - @Nonnull Object underlyingObject); + @NonNull + List getContextActions(@NonNull KeYMediator mediator, @NonNull ContextMenuKind kind, + @NonNull Object underlyingObject); } /** @@ -166,7 +166,7 @@ interface Toolbar { * @param mainWindow the parent of the toolbar * @return non-null */ - @Nonnull + @NonNull JToolBar getToolbar(MainWindow mainWindow); } @@ -251,8 +251,8 @@ interface TermInfo { * @param pos the position of the term whose info shall be shown. * @return this extension's term information. */ - @Nonnull - List getTermInfoStrings(@Nonnull MainWindow mainWindow, @Nonnull PosInSequent pos); + @NonNull + List getTermInfoStrings(@NonNull MainWindow mainWindow, @NonNull PosInSequent pos); default int getTermLabelPriority() { return 0; diff --git a/key.ui/src/main/java/de/uka/ilkd/key/gui/extension/api/TabPanel.java b/key.ui/src/main/java/de/uka/ilkd/key/gui/extension/api/TabPanel.java index 0331035bf9f..c64a28382fc 100644 --- a/key.ui/src/main/java/de/uka/ilkd/key/gui/extension/api/TabPanel.java +++ b/key.ui/src/main/java/de/uka/ilkd/key/gui/extension/api/TabPanel.java @@ -2,8 +2,8 @@ import java.util.Collection; import java.util.Collections; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import org.jspecify.annotations.NonNull; +import org.jspecify.annotations.Nullable; import javax.swing.*; import bibliothek.gui.dock.common.action.CAction; @@ -14,27 +14,27 @@ * @version 1 (23.04.19) */ public interface TabPanel { - @Nonnull + @NonNull String getTitle(); default @Nullable Icon getIcon() { return null; } - @Nonnull + @NonNull JComponent getComponent(); /** * @return non-null */ - default @Nonnull Collection getTitleActions() { + default @NonNull Collection getTitleActions() { return Collections.emptyList(); } /** * @return */ - default @Nonnull Collection getTitleCActions() { + default @NonNull Collection getTitleCActions() { return Collections.emptyList(); } diff --git a/key.ui/src/main/java/de/uka/ilkd/key/gui/extension/impl/TestExtension.java b/key.ui/src/main/java/de/uka/ilkd/key/gui/extension/impl/TestExtension.java index 58d812979d4..5236b469919 100644 --- a/key.ui/src/main/java/de/uka/ilkd/key/gui/extension/impl/TestExtension.java +++ b/key.ui/src/main/java/de/uka/ilkd/key/gui/extension/impl/TestExtension.java @@ -6,7 +6,7 @@ import java.util.Collection; import java.util.Collections; import java.util.List; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; import javax.swing.*; import de.uka.ilkd.key.core.KeYMediator; @@ -96,10 +96,10 @@ public SettingsProvider getSettings() { return new TestSettingsProvider(); } - @Nonnull + @NonNull @Override - public Collection getPanels(@Nonnull MainWindow window, - @Nonnull KeYMediator mediator) { + public Collection getPanels(@NonNull MainWindow window, + @NonNull KeYMediator mediator) { return Collections.singleton(new TabPanel() { @Override public String getTitle() { diff --git a/key.ui/src/main/java/de/uka/ilkd/key/gui/lemmatagenerator/LemmataHandler.java b/key.ui/src/main/java/de/uka/ilkd/key/gui/lemmatagenerator/LemmataHandler.java index b252509b537..4ea864cb738 100644 --- a/key.ui/src/main/java/de/uka/ilkd/key/gui/lemmatagenerator/LemmataHandler.java +++ b/key.ui/src/main/java/de/uka/ilkd/key/gui/lemmatagenerator/LemmataHandler.java @@ -5,7 +5,7 @@ import java.util.Collection; import java.util.LinkedList; import java.util.List; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.proof.Proof; diff --git a/key.ui/src/main/java/de/uka/ilkd/key/gui/nodeviews/SequentViewSearchBar.java b/key.ui/src/main/java/de/uka/ilkd/key/gui/nodeviews/SequentViewSearchBar.java index a4a8261a43e..91c9227f2fb 100644 --- a/key.ui/src/main/java/de/uka/ilkd/key/gui/nodeviews/SequentViewSearchBar.java +++ b/key.ui/src/main/java/de/uka/ilkd/key/gui/nodeviews/SequentViewSearchBar.java @@ -6,7 +6,7 @@ import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; import javax.swing.*; import de.uka.ilkd.key.gui.SearchBar; @@ -165,7 +165,7 @@ public void setVisible(boolean vis) { * searches for the occurrence of the specified string */ @Override - public boolean search(@Nonnull String search) { + public boolean search(@NonNull String search) { clearSearchResults(); if (sequentView.getFilter() instanceof SearchSequentPrintFilter) { diff --git a/key.ui/src/main/java/de/uka/ilkd/key/gui/plugins/javac/JavaCompilerCheckFacade.java b/key.ui/src/main/java/de/uka/ilkd/key/gui/plugins/javac/JavaCompilerCheckFacade.java index 101939d21b2..df468264103 100644 --- a/key.ui/src/main/java/de/uka/ilkd/key/gui/plugins/javac/JavaCompilerCheckFacade.java +++ b/key.ui/src/main/java/de/uka/ilkd/key/gui/plugins/javac/JavaCompilerCheckFacade.java @@ -12,7 +12,7 @@ import java.util.*; import java.util.concurrent.CompletableFuture; import java.util.stream.Collectors; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; import javax.tools.*; import de.uka.ilkd.key.gui.PositionedIssueString; @@ -55,7 +55,7 @@ public class JavaCompilerCheckFacade { * @param javaPath the {@link String} with the path to the source of the target Java program * @return future providing the list of diagnostics */ - @Nonnull + @NonNull public static CompletableFuture> check( ProblemInitializer.ProblemInitializerListener listener, File bootClassPath, List classPath, File javaPath) { diff --git a/key.ui/src/main/java/de/uka/ilkd/key/gui/prooftree/GUIAbstractTreeNode.java b/key.ui/src/main/java/de/uka/ilkd/key/gui/prooftree/GUIAbstractTreeNode.java index de1bc0b2769..cc417773884 100644 --- a/key.ui/src/main/java/de/uka/ilkd/key/gui/prooftree/GUIAbstractTreeNode.java +++ b/key.ui/src/main/java/de/uka/ilkd/key/gui/prooftree/GUIAbstractTreeNode.java @@ -4,7 +4,7 @@ import java.lang.ref.WeakReference; import java.util.Enumeration; import java.util.LinkedList; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; import javax.swing.tree.TreeNode; import de.uka.ilkd.key.proof.Node; @@ -37,7 +37,7 @@ public GUIAbstractTreeNode(GUIProofTreeModel tree, Node node) { public abstract void flushCache(); - public abstract @Nonnull String getSearchString(); + public abstract @NonNull String getSearchString(); public int getIndex(TreeNode node) { for (int i = 0; i < getChildCount(); i++) { diff --git a/key.ui/src/main/java/de/uka/ilkd/key/gui/prooftree/GUIBranchNode.java b/key.ui/src/main/java/de/uka/ilkd/key/gui/prooftree/GUIBranchNode.java index 33b65aa6989..54cd8094bee 100644 --- a/key.ui/src/main/java/de/uka/ilkd/key/gui/prooftree/GUIBranchNode.java +++ b/key.ui/src/main/java/de/uka/ilkd/key/gui/prooftree/GUIBranchNode.java @@ -3,7 +3,7 @@ * this class implements a TreeModel that can be displayed using the JTree class framework */ -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; import javax.swing.tree.TreeNode; import de.uka.ilkd.key.proof.Node; @@ -74,7 +74,7 @@ public void flushCache() { childrenCache = null; } - @Nonnull + @NonNull @Override public String getSearchString() { return toString(); diff --git a/key.ui/src/main/java/de/uka/ilkd/key/gui/prooftree/GUIOneStepChildTreeNode.java b/key.ui/src/main/java/de/uka/ilkd/key/gui/prooftree/GUIOneStepChildTreeNode.java index 49d51e8921c..4f3fa4d2cf6 100644 --- a/key.ui/src/main/java/de/uka/ilkd/key/gui/prooftree/GUIOneStepChildTreeNode.java +++ b/key.ui/src/main/java/de/uka/ilkd/key/gui/prooftree/GUIOneStepChildTreeNode.java @@ -1,6 +1,6 @@ package de.uka.ilkd.key.gui.prooftree; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; import javax.swing.tree.TreeNode; import de.uka.ilkd.key.java.Services; @@ -69,7 +69,7 @@ public void flushCache() { // nothing to do } - @Nonnull + @NonNull @Override public String getSearchString() { return toString(); diff --git a/key.ui/src/main/java/de/uka/ilkd/key/gui/prooftree/GUIProofTreeModel.java b/key.ui/src/main/java/de/uka/ilkd/key/gui/prooftree/GUIProofTreeModel.java index 812ab3c02d8..da109fd40b9 100644 --- a/key.ui/src/main/java/de/uka/ilkd/key/gui/prooftree/GUIProofTreeModel.java +++ b/key.ui/src/main/java/de/uka/ilkd/key/gui/prooftree/GUIProofTreeModel.java @@ -1,7 +1,7 @@ package de.uka.ilkd.key.gui.prooftree; import java.util.*; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; import javax.swing.event.EventListenerList; import javax.swing.event.TreeModelEvent; import javax.swing.event.TreeModelListener; @@ -508,13 +508,13 @@ public GUIBranchNode getBranchNode(Node n, Object label) { /** stores exactly the paths that are expanded in the proof tree */ - private @Nonnull Collection expansionState = Collections.emptySet(); + private @NonNull Collection expansionState = Collections.emptySet(); - public void setExpansionState(@Nonnull Collection c) { + public void setExpansionState(@NonNull Collection c) { expansionState = c; } - public @Nonnull Collection getExpansionState() { + public @NonNull Collection getExpansionState() { return expansionState; } diff --git a/key.ui/src/main/java/de/uka/ilkd/key/gui/prooftree/GUIProofTreeNode.java b/key.ui/src/main/java/de/uka/ilkd/key/gui/prooftree/GUIProofTreeNode.java index e1a73e42ea5..e01bbdf3b70 100644 --- a/key.ui/src/main/java/de/uka/ilkd/key/gui/prooftree/GUIProofTreeNode.java +++ b/key.ui/src/main/java/de/uka/ilkd/key/gui/prooftree/GUIProofTreeNode.java @@ -3,7 +3,7 @@ * this class implements a TreeModel that can be displayed using the JTree class framework */ -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; import javax.swing.tree.TreeNode; import de.uka.ilkd.key.proof.Node; @@ -87,7 +87,7 @@ public void flushCache() { children = null; } - @Nonnull + @NonNull @Override public String getSearchString() { return toString(); diff --git a/key.ui/src/main/java/de/uka/ilkd/key/gui/prooftree/ProofTreeExpansionState.java b/key.ui/src/main/java/de/uka/ilkd/key/gui/prooftree/ProofTreeExpansionState.java index 9257b60b444..566420b3eb9 100644 --- a/key.ui/src/main/java/de/uka/ilkd/key/gui/prooftree/ProofTreeExpansionState.java +++ b/key.ui/src/main/java/de/uka/ilkd/key/gui/prooftree/ProofTreeExpansionState.java @@ -8,7 +8,7 @@ import java.util.*; import java.util.function.Predicate; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; import javax.swing.JTree; import javax.swing.event.*; import javax.swing.tree.TreeModel; @@ -83,7 +83,7 @@ class ProofTreeExpansionState extends AbstractSet { /** the JTree of the ProofTreeView */ - private final @Nonnull JTree tree; + private final @NonNull JTree tree; /** * Stores all paths that are currently expanded. This includes those which are hidden because @@ -92,10 +92,10 @@ class ProofTreeExpansionState extends AbstractSet { * @implNote We always use a LinkedHashSet now since this makes the path traversal order * predictable. */ - private final @Nonnull Set paths = new LinkedHashSet<>(); + private final @NonNull Set paths = new LinkedHashSet<>(); /** Listens for changes in the proof tree as well as for expansion/collapse of GUI nodes. */ - private final @Nonnull Listener listener = new Listener(); + private final @NonNull Listener listener = new Listener(); /** * For the given JTree. Assumes only the root is expanded, if at all (for example, a freshly @@ -103,7 +103,7 @@ class ProofTreeExpansionState extends AbstractSet { * * @param t the JTree of the ProofTreeView */ - public ProofTreeExpansionState(@Nonnull JTree t) { + public ProofTreeExpansionState(@NonNull JTree t) { tree = t; tree.addTreeExpansionListener(listener); @@ -126,7 +126,7 @@ public ProofTreeExpansionState(@Nonnull JTree t) { * @param tree the JTree this ProofExpansionState refers to * @param state the collection of paths to expand initially */ - public ProofTreeExpansionState(@Nonnull JTree tree, @Nonnull Collection state) { + public ProofTreeExpansionState(@NonNull JTree tree, @NonNull Collection state) { this(tree); setPaths(tree, state); } @@ -226,7 +226,7 @@ protected Object clone() throws CloneNotSupportedException { * * @return a shallow copy of the collection of expanded paths */ - public @Nonnull Collection copyState() { + public @NonNull Collection copyState() { // we need a copy here, such that the set is not shared between multiple trees! return new LinkedHashSet<>(paths); } @@ -475,7 +475,7 @@ private static void pathsImpl(JTree tree, TreeModel data, TreePath path, * @param paths the paths to expand. All other paths will be collapsed. Note that collapsed * parent paths may hide their children, even if those are expanded. */ - public static void setPaths(@Nonnull JTree tree, @Nonnull Collection paths) { + public static void setPaths(@NonNull JTree tree, @NonNull Collection paths) { TreeModel data = tree.getModel(); if (data == null) { @@ -509,8 +509,8 @@ public static void setPaths(@Nonnull JTree tree, @Nonnull Collection p tree.fireTreeExpanded(new TreePath(root)); } - private static void setPathsImpl(@Nonnull JTree tree, @Nonnull TreeModel data, - @Nonnull TreePath start, int maxLevel, @Nonnull Collection paths) { + private static void setPathsImpl(@NonNull JTree tree, @NonNull TreeModel data, + @NonNull TreePath start, int maxLevel, @NonNull Collection paths) { // only expand up to depth maxLevel starting from the given start path if (maxLevel > 0) { Object node = start.getLastPathComponent(); diff --git a/key.ui/src/main/java/de/uka/ilkd/key/gui/prooftree/ProofTreeSearchBar.java b/key.ui/src/main/java/de/uka/ilkd/key/gui/prooftree/ProofTreeSearchBar.java index de63ce022ca..4e5dcdb72ef 100644 --- a/key.ui/src/main/java/de/uka/ilkd/key/gui/prooftree/ProofTreeSearchBar.java +++ b/key.ui/src/main/java/de/uka/ilkd/key/gui/prooftree/ProofTreeSearchBar.java @@ -2,7 +2,7 @@ import java.util.ArrayList; import java.util.List; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; import javax.swing.event.TreeModelEvent; import javax.swing.event.TreeModelListener; import javax.swing.text.Position; @@ -44,7 +44,7 @@ public void searchPrevious() { search(searchField.getText(), Position.Bias.Backward); } - public boolean search(@Nonnull String searchString) { + public boolean search(@NonNull String searchString) { fillCache(); return search(searchString, Position.Bias.Forward); } @@ -119,7 +119,7 @@ private void fillCacheHelp(GUIBranchNode branch) { } } - private int getNextMatch(@Nonnull String searchString, int startingRow, Position.Bias bias) { + private int getNextMatch(@NonNull String searchString, int startingRow, Position.Bias bias) { String s = searchString.toLowerCase(); if (bias == Position.Bias.Forward) { @@ -161,7 +161,7 @@ private int getNextMatch(@Nonnull String searchString, int startingRow, Position * @param searchString the String to be looked for * @return true if a match has been found */ - private boolean nodeContainsString(int node, @Nonnull String searchString) { + private boolean nodeContainsString(int node, @NonNull String searchString) { return cache.get(node).second.contains(searchString); } } diff --git a/key.ui/src/main/java/de/uka/ilkd/key/gui/prooftree/ProofTreeView.java b/key.ui/src/main/java/de/uka/ilkd/key/gui/prooftree/ProofTreeView.java index 82e0de80798..091a73060d0 100644 --- a/key.ui/src/main/java/de/uka/ilkd/key/gui/prooftree/ProofTreeView.java +++ b/key.ui/src/main/java/de/uka/ilkd/key/gui/prooftree/ProofTreeView.java @@ -4,7 +4,7 @@ import java.awt.event.*; import java.util.*; import java.util.List; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; import javax.swing.*; import javax.swing.event.TreeSelectionEvent; import javax.swing.event.TreeSelectionListener; @@ -644,7 +644,7 @@ public void showSearchPanel() { proofTreeSearchPanel.setVisible(true); } - @Nonnull + @NonNull @Override public String getTitle() { return "Proof"; @@ -655,7 +655,7 @@ public Icon getIcon() { return IconFactory.PROOF_TREE.get(IconFactory.DEFAULT_SIZE); } - @Nonnull + @NonNull @Override public JComponent getComponent() { return this; @@ -737,7 +737,7 @@ public boolean setFilter(ProofTreeViewFilter filter, boolean selected) { return true; } - @Nonnull + @NonNull @Override public Collection getTitleCActions() { return List.of(ProofTreeSettingsMenuFactory.create(this)); diff --git a/key.ui/src/main/java/de/uka/ilkd/key/gui/prooftree/Style.java b/key.ui/src/main/java/de/uka/ilkd/key/gui/prooftree/Style.java index 5e0f4cb7b2b..ec9482be3eb 100644 --- a/key.ui/src/main/java/de/uka/ilkd/key/gui/prooftree/Style.java +++ b/key.ui/src/main/java/de/uka/ilkd/key/gui/prooftree/Style.java @@ -4,7 +4,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; import javax.swing.Icon; import de.uka.ilkd.key.pp.LogicPrinter; @@ -63,7 +63,7 @@ public void setTitle(String title) { * @param value the value * @param block whether this should be rendered as a block */ - public void addAdditionalInfo(@Nonnull String key, @Nonnull String value, boolean block) { + public void addAdditionalInfo(@NonNull String key, @NonNull String value, boolean block) { additionalInfo.add(new Fragment(key, value, block)); } @@ -72,7 +72,7 @@ public void addAdditionalInfo(@Nonnull String key, @Nonnull String value, boolea * * @param notes the notes */ - public void addNotes(@Nonnull String notes) { + public void addNotes(@NonNull String notes) { addAdditionalInfo("Notes", notes, false); } @@ -81,7 +81,7 @@ public void addNotes(@Nonnull String notes) { * * @param rule the rule */ - public void addRule(@Nonnull String rule) { + public void addRule(@NonNull String rule) { addAdditionalInfo("Rule", rule, false); } @@ -90,7 +90,7 @@ public void addRule(@Nonnull String rule) { * * @param on the info */ - public void addAppliedOn(@Nonnull String on) { + public void addAppliedOn(@NonNull String on) { addAdditionalInfo("Applied on", LogicPrinter.escapeHTML(on, true), true); } diff --git a/key.ui/src/main/java/de/uka/ilkd/key/gui/prooftree/Styler.java b/key.ui/src/main/java/de/uka/ilkd/key/gui/prooftree/Styler.java index 372926a9092..1467d72e66d 100644 --- a/key.ui/src/main/java/de/uka/ilkd/key/gui/prooftree/Styler.java +++ b/key.ui/src/main/java/de/uka/ilkd/key/gui/prooftree/Styler.java @@ -1,6 +1,6 @@ package de.uka.ilkd.key.gui.prooftree; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; /** * A {@code Styler} is a part of a strategy to implement a flexible mechanism for the representation @@ -16,5 +16,5 @@ public interface Styler { * Set the required style information in {@code current} accordingly to the object given in * {@code obj}. */ - void style(@Nonnull Style current, @Nonnull T obj); + void style(@NonNull Style current, @NonNull T obj); } diff --git a/key.ui/src/main/java/de/uka/ilkd/key/gui/settings/SettingsPanel.java b/key.ui/src/main/java/de/uka/ilkd/key/gui/settings/SettingsPanel.java index 9ed74bf8288..bf37e403436 100644 --- a/key.ui/src/main/java/de/uka/ilkd/key/gui/settings/SettingsPanel.java +++ b/key.ui/src/main/java/de/uka/ilkd/key/gui/settings/SettingsPanel.java @@ -5,7 +5,7 @@ import java.io.File; import java.util.Arrays; import java.util.List; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; import javax.swing.*; import de.uka.ilkd.key.gui.KeYFileChooser; diff --git a/key.ui/src/main/java/de/uka/ilkd/key/gui/settings/SimpleSettingsPanel.java b/key.ui/src/main/java/de/uka/ilkd/key/gui/settings/SimpleSettingsPanel.java index 37d328b4088..0697d0a7fb0 100644 --- a/key.ui/src/main/java/de/uka/ilkd/key/gui/settings/SimpleSettingsPanel.java +++ b/key.ui/src/main/java/de/uka/ilkd/key/gui/settings/SimpleSettingsPanel.java @@ -3,7 +3,7 @@ import java.awt.*; import java.text.Format; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; import javax.swing.*; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; diff --git a/key.ui/src/main/java/de/uka/ilkd/key/gui/settings/TacletOptionsSettings.java b/key.ui/src/main/java/de/uka/ilkd/key/gui/settings/TacletOptionsSettings.java index 52fb3f9f010..3e29a9155ea 100644 --- a/key.ui/src/main/java/de/uka/ilkd/key/gui/settings/TacletOptionsSettings.java +++ b/key.ui/src/main/java/de/uka/ilkd/key/gui/settings/TacletOptionsSettings.java @@ -11,7 +11,7 @@ import java.util.*; import java.util.List; import java.util.stream.Collectors; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; import javax.swing.*; import de.uka.ilkd.key.gui.MainWindow; @@ -217,7 +217,7 @@ protected void addExplanation(String explanation) { pCenter.add(p, new CC().span().newline()); } - @Nonnull + @NonNull private JPanel createCollapsibleTitlePane(String titleText, JComponent child) { JPanel p = new JPanel(new BorderLayout()); JPanel north = new JPanel(new BorderLayout()); diff --git a/key.util/build.gradle b/key.util/build.gradle index 3cbc8f1ed38..a90129a9070 100644 --- a/key.util/build.gradle +++ b/key.util/build.gradle @@ -2,14 +2,16 @@ dependencies{ } checkerFramework { - checkers = [ - "org.checkerframework.checker.nullness.NullnessChecker", - ] - extraJavacArgs = [ - "-AonlyDefs=^org\\.key_project\\.util", - "-Xmaxerrs", "10000", - "-Astubs=$projectDir/src/main/checkerframework", - "-Werror", - "-Aversion", - ] + if(System.getProperty("ENABLE_NULLNESS")) { + checkers = [ + "org.checkerframework.checker.nullness.NullnessChecker", + ] + extraJavacArgs = [ + "-AonlyDefs=^org\\.key_project\\.util", + "-Xmaxerrs", "10000", + "-Astubs=$projectDir/src/main/checkerframework", + "-Werror", + "-Aversion", + ] + } } \ No newline at end of file diff --git a/key.util/src/main/java/org/key_project/util/collection/ImmutableArray.java b/key.util/src/main/java/org/key_project/util/collection/ImmutableArray.java index 29619b553cd..7afa9af5dae 100644 --- a/key.util/src/main/java/org/key_project/util/collection/ImmutableArray.java +++ b/key.util/src/main/java/org/key_project/util/collection/ImmutableArray.java @@ -8,7 +8,7 @@ import java.util.List; import java.util.stream.Stream; import java.util.stream.StreamSupport; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; @SuppressWarnings("nullness") public class ImmutableArray implements java.lang.Iterable, java.io.Serializable { @@ -48,7 +48,7 @@ public ImmutableArray(S... arr) { * @param list a non-null collection (order is preserved) */ @SuppressWarnings("unchecked") - public ImmutableArray(@Nonnull Collection list) { + public ImmutableArray(@NonNull Collection list) { content = (S[]) list.toArray(); } diff --git a/keyext.exploration/src/main/java/org/key_project/exploration/ExplorationExtension.java b/keyext.exploration/src/main/java/org/key_project/exploration/ExplorationExtension.java index 84fe0486caf..bb779c8d140 100644 --- a/keyext.exploration/src/main/java/org/key_project/exploration/ExplorationExtension.java +++ b/keyext.exploration/src/main/java/org/key_project/exploration/ExplorationExtension.java @@ -5,7 +5,7 @@ import java.util.Collection; import java.util.Collections; import java.util.List; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; import javax.swing.*; import de.uka.ilkd.key.core.KeYMediator; @@ -70,14 +70,14 @@ public void proofPruned(de.uka.ilkd.key.proof.ProofTreeEvent e) { } }; - @Nonnull + @NonNull @Override - public List getContextActions(@Nonnull KeYMediator mediator, - @Nonnull ContextMenuKind kind, @Nonnull Object underlyingObject) { + public List getContextActions(@NonNull KeYMediator mediator, + @NonNull ContextMenuKind kind, @NonNull Object underlyingObject) { return adapter.getContextActions(mediator, kind, underlyingObject); } - @Nonnull + @NonNull @Override public JToolBar getToolbar(MainWindow mainWindow) { if (explorationToolbar == null) { @@ -119,17 +119,17 @@ public void selectedProofChanged(KeYSelectionEvent e) { window.getProofTreeView().getRenderer().add(new ExplorationRenderer()); } - private void initLeftPanel(@Nonnull MainWindow window) { + private void initLeftPanel(@NonNull MainWindow window) { leftPanel = new ExplorationStepsList(window); leftPanel.setEnabled(model.isExplorationModeSelected()); model.addPropertyChangeListener(ExplorationModeModel.PROP_EXPLORE_MODE, e -> leftPanel.setEnabled(model.isExplorationModeSelected())); } - @Nonnull + @NonNull @Override - public Collection getPanels(@Nonnull MainWindow window, - @Nonnull KeYMediator mediator) { + public Collection getPanels(@NonNull MainWindow window, + @NonNull KeYMediator mediator) { if (leftPanel == null) { initLeftPanel(window); } @@ -147,7 +147,7 @@ public List getStatusLineComponents() { } @Override - public @Nonnull List getMainMenuActions(@Nonnull MainWindow mainWindow) { + public @NonNull List getMainMenuActions(@NonNull MainWindow mainWindow) { return Arrays.asList(new ToggleExplorationAction(model, mainWindow), new ShowInteractiveBranchesAction(model, mainWindow)); } @@ -173,7 +173,7 @@ class ExplorationRenderer implements Styler { ColorSettings.define("[proofTree]lightPurple", "", new Color(165, 146, 191)); @Override - public void style(@Nonnull Style style, GUIAbstractTreeNode treeNode) { + public void style(@NonNull Style style, GUIAbstractTreeNode treeNode) { Node node = treeNode.getNode(); ExplorationNodeData data = node.lookup(ExplorationNodeData.class); diff --git a/keyext.exploration/src/main/java/org/key_project/exploration/ExplorationModeModel.java b/keyext.exploration/src/main/java/org/key_project/exploration/ExplorationModeModel.java index 68074e5ff9e..9c521bc17e1 100644 --- a/keyext.exploration/src/main/java/org/key_project/exploration/ExplorationModeModel.java +++ b/keyext.exploration/src/main/java/org/key_project/exploration/ExplorationModeModel.java @@ -5,7 +5,7 @@ import java.util.Map; import java.util.WeakHashMap; import java.util.concurrent.atomic.AtomicInteger; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.gui.MainWindow; import de.uka.ilkd.key.gui.prooftree.GUIProofTreeModel; @@ -35,7 +35,7 @@ public class ExplorationModeModel { /** * Mode which rules to use in actions mode Default: whole application is shown */ - private @Nonnull ExplorationState explorationTacletAppState = ExplorationState.WHOLE_APP; + private @NonNull ExplorationState explorationTacletAppState = ExplorationState.WHOLE_APP; /** @@ -47,7 +47,7 @@ public class ExplorationModeModel { /** * Get the state which kind of taclet to use */ - public @Nonnull ExplorationState getExplorationTacletAppState() { + public @NonNull ExplorationState getExplorationTacletAppState() { return explorationTacletAppState; } diff --git a/keyext.exploration/src/main/java/org/key_project/exploration/ExplorationNodeData.java b/keyext.exploration/src/main/java/org/key_project/exploration/ExplorationNodeData.java index d3aba15354d..12f8e092918 100644 --- a/keyext.exploration/src/main/java/org/key_project/exploration/ExplorationNodeData.java +++ b/keyext.exploration/src/main/java/org/key_project/exploration/ExplorationNodeData.java @@ -1,8 +1,8 @@ package org.key_project.exploration; import java.util.Objects; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import org.jspecify.annotations.NonNull; +import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.proof.Node; @@ -15,7 +15,7 @@ public class ExplorationNodeData { private String explorationAction; - public static @Nonnull ExplorationNodeData get(@Nonnull Node node) { + public static @NonNull ExplorationNodeData get(@NonNull Node node) { @Nullable ExplorationNodeData data = node.lookup(ExplorationNodeData.class); if (data == null) { diff --git a/keyext.exploration/src/main/java/org/key_project/exploration/ProofExplorationService.java b/keyext.exploration/src/main/java/org/key_project/exploration/ProofExplorationService.java index a4fcc2b0ee8..dff4bccf9a9 100644 --- a/keyext.exploration/src/main/java/org/key_project/exploration/ProofExplorationService.java +++ b/keyext.exploration/src/main/java/org/key_project/exploration/ProofExplorationService.java @@ -1,8 +1,8 @@ package org.key_project.exploration; import java.util.Objects; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import org.jspecify.annotations.NonNull; +import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.core.KeYMediator; import de.uka.ilkd.key.java.Services; @@ -40,19 +40,19 @@ */ public class ProofExplorationService { - private final @Nonnull Proof proof; - private final @Nonnull Services services; + private final @NonNull Proof proof; + private final @NonNull Services services; - public ProofExplorationService(@Nonnull Proof proof, @Nonnull Services services) { + public ProofExplorationService(@NonNull Proof proof, @NonNull Services services) { this.proof = proof; this.services = services; } - public static @Nonnull ProofExplorationService get(KeYMediator mediator) { + public static @NonNull ProofExplorationService get(KeYMediator mediator) { return get(mediator.getSelectedProof()); } - private static @Nonnull ProofExplorationService get(Proof selectedProof) { + private static @NonNull ProofExplorationService get(Proof selectedProof) { @Nullable ProofExplorationService service = selectedProof.lookup(ProofExplorationService.class); if (service == null) { @@ -74,7 +74,7 @@ private FindTaclet getHideTaclet(boolean inAntec) { /** * Finds the `cut` taclet in the current proof environment. */ - public @Nonnull Taclet getCutTaclet() { + public @NonNull Taclet getCutTaclet() { return Objects.requireNonNull( proof.getEnv().getInitConfigForEnvironment().lookupActiveTaclet(new Name("cut"))); } @@ -86,7 +86,7 @@ private FindTaclet getHideTaclet(boolean inAntec) { * @param t Term to add to teh sequent * @param antecedent whether to add teh term to antecedent */ - public @Nonnull Node soundAddition(@Nonnull Goal g, @Nonnull Term t, boolean antecedent) { + public @NonNull Node soundAddition(@NonNull Goal g, @NonNull Term t, boolean antecedent) { Taclet cut = g.proof().getEnv().getInitConfigForEnvironment().lookupActiveTaclet(new Name("cut")); Semisequent semisequent = new Semisequent(new SequentFormula(t)); @@ -126,12 +126,12 @@ private FindTaclet getHideTaclet(boolean inAntec) { return toBeSelected; } - public Node applyChangeFormula(@Nonnull Goal g, @Nonnull PosInOccurrence pio, - @Nonnull Term term, @Nonnull Term newTerm) { + public Node applyChangeFormula(@NonNull Goal g, @NonNull PosInOccurrence pio, + @NonNull Term term, @NonNull Term newTerm) { TacletApp app = soundChange(pio, term, newTerm); // taint goal with exploration - @Nonnull + @NonNull ExplorationNodeData data = ExplorationNodeData.get(g.node()); data.setExplorationAction( String.format("Edit %s to %s", LogicPrinter.quickPrintTerm(term, services), @@ -167,8 +167,8 @@ public Node applyChangeFormula(@Nonnull Goal g, @Nonnull PosInOccurrence pio, return toBeSelected; } - private TacletApp soundChange(@Nonnull PosInOccurrence pio, @Nonnull Term term, - @Nonnull Term newTerm) { + private TacletApp soundChange(@NonNull PosInOccurrence pio, @NonNull Term term, + @NonNull Term newTerm) { Taclet cut = getCutTaclet(); Semisequent semisequent = new Semisequent(new SequentFormula(newTerm)); TacletApp app = NoPosTacletApp.createNoPosTacletApp(cut); diff --git a/keyext.exploration/src/main/java/org/key_project/exploration/actions/AddFormulaToAntecedentAction.java b/keyext.exploration/src/main/java/org/key_project/exploration/actions/AddFormulaToAntecedentAction.java index bd6a0693d4a..10f70fd7d73 100644 --- a/keyext.exploration/src/main/java/org/key_project/exploration/actions/AddFormulaToAntecedentAction.java +++ b/keyext.exploration/src/main/java/org/key_project/exploration/actions/AddFormulaToAntecedentAction.java @@ -1,7 +1,7 @@ package org.key_project.exploration.actions; import java.awt.event.ActionEvent; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.gui.MainWindow; import de.uka.ilkd.key.logic.Term; @@ -31,7 +31,7 @@ public void actionPerformed(ActionEvent e) { return; } ProofExplorationService service = ProofExplorationService.get(getMediator()); - @Nonnull + @NonNull Node toBeSelected = service.soundAddition(getMediator().getSelectedGoal(), t, true); getMediator().getSelectionModel().setSelectedNode(toBeSelected); } diff --git a/keyext.exploration/src/main/java/org/key_project/exploration/actions/AddFormulaToSuccedentAction.java b/keyext.exploration/src/main/java/org/key_project/exploration/actions/AddFormulaToSuccedentAction.java index 0358d753b19..c07081919aa 100644 --- a/keyext.exploration/src/main/java/org/key_project/exploration/actions/AddFormulaToSuccedentAction.java +++ b/keyext.exploration/src/main/java/org/key_project/exploration/actions/AddFormulaToSuccedentAction.java @@ -1,7 +1,7 @@ package org.key_project.exploration.actions; import java.awt.event.ActionEvent; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.gui.MainWindow; import de.uka.ilkd.key.logic.Term; @@ -32,7 +32,7 @@ public void actionPerformed(ActionEvent e) { return; } ProofExplorationService service = ProofExplorationService.get(getMediator()); - @Nonnull + @NonNull Node toBeSelected = service.soundAddition(getMediator().getSelectedGoal(), t, false); getMediator().getSelectionModel().setSelectedNode(toBeSelected); } diff --git a/keyext.exploration/src/main/java/org/key_project/exploration/ui/ExplorationStepsList.java b/keyext.exploration/src/main/java/org/key_project/exploration/ui/ExplorationStepsList.java index 637cf365365..d2cef44faac 100644 --- a/keyext.exploration/src/main/java/org/key_project/exploration/ui/ExplorationStepsList.java +++ b/keyext.exploration/src/main/java/org/key_project/exploration/ui/ExplorationStepsList.java @@ -4,8 +4,8 @@ import java.awt.event.ActionEvent; import java.util.*; import java.util.List; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import org.jspecify.annotations.NonNull; +import org.jspecify.annotations.Nullable; import javax.swing.*; import javax.swing.tree.*; @@ -117,7 +117,7 @@ private List collectAllExplorationSteps(Node root, DefaultTreeModel dtm, } @Override - public @Nonnull Collection getTitleCActions() { + public @NonNull Collection getTitleCActions() { return Collections.singleton(HelpFacade.createHelpButton("user/Exploration/")); } @@ -133,9 +133,9 @@ private List collectAllExplorationSteps(Node root, DefaultTreeModel dtm, * @param dtm a tree model which is filled with nodes * @param parent the corresponding entry of {@code n} in the tree model */ - private void findExplorationChildren(@Nonnull Node node, - final @Nonnull ArrayList foundNodes, @Nonnull DefaultTreeModel dtm, - @Nonnull MyTreeNode parent) { + private void findExplorationChildren(@NonNull Node node, + final @NonNull ArrayList foundNodes, @NonNull DefaultTreeModel dtm, + @NonNull MyTreeNode parent) { Set reached = new HashSet<>(512000); ArrayDeque nodes = new ArrayDeque<>(8); nodes.add(node); @@ -219,13 +219,13 @@ private JPanel createBottomPanel() { return buttonPanel; } - @Nonnull + @NonNull @Override public String getTitle() { return "Exploration Steps"; } - @Nonnull + @NonNull @Override public JComponent getComponent() { return this; diff --git a/keyext.slicing/src/main/java/org/key_project/slicing/SlicingExtension.java b/keyext.slicing/src/main/java/org/key_project/slicing/SlicingExtension.java index 0d2807359cd..d6edfd35274 100644 --- a/keyext.slicing/src/main/java/org/key_project/slicing/SlicingExtension.java +++ b/keyext.slicing/src/main/java/org/key_project/slicing/SlicingExtension.java @@ -6,7 +6,7 @@ import java.util.IdentityHashMap; import java.util.List; import java.util.Map; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; import javax.swing.*; import de.uka.ilkd.key.core.KeYMediator; @@ -100,11 +100,11 @@ public List getContextActions( } }; - @Nonnull + @NonNull @Override - public List getContextActions(@Nonnull KeYMediator mediator, - @Nonnull ContextMenuKind kind, - @Nonnull Object underlyingObject) { + public List getContextActions(@NonNull KeYMediator mediator, + @NonNull ContextMenuKind kind, + @NonNull Object underlyingObject) { return adapter.getContextActions(mediator, kind, underlyingObject); } @@ -139,10 +139,10 @@ private void createTrackerForProof(Proof newProof) { }); } - @Nonnull + @NonNull @Override public Collection getPanels( - @Nonnull MainWindow window, @Nonnull KeYMediator mediator) { + @NonNull MainWindow window, @NonNull KeYMediator mediator) { if (leftPanel == null) { leftPanel = new SlicingLeftPanel(mediator, this); mediator.addKeYSelectionListener(leftPanel); diff --git a/keyext.slicing/src/main/java/org/key_project/slicing/ui/SlicingLeftPanel.java b/keyext.slicing/src/main/java/org/key_project/slicing/ui/SlicingLeftPanel.java index e788b9b5308..d41eb87e9d4 100644 --- a/keyext.slicing/src/main/java/org/key_project/slicing/ui/SlicingLeftPanel.java +++ b/keyext.slicing/src/main/java/org/key_project/slicing/ui/SlicingLeftPanel.java @@ -12,7 +12,7 @@ import java.util.List; import java.util.Optional; import java.util.stream.Collectors; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; import javax.swing.*; import javax.swing.border.TitledBorder; @@ -359,7 +359,7 @@ private GridBagConstraints gridBagConstraints(int y) { return c; } - @Nonnull + @NonNull @Override public Collection getTitleCActions() { return List.of(HelpFacade.createHelpButton("user/ProofSlicing/")); @@ -532,7 +532,7 @@ private void displayGraphLabels() { graphEdges.setText("Graph edges: " + graphEdgesNr); } - @Nonnull + @NonNull @Override public String getTitle() { return "Proof Slicing"; @@ -543,7 +543,7 @@ public Icon getIcon() { return INFO_ICON; } - @Nonnull + @NonNull @Override public JComponent getComponent() { return this; diff --git a/keyext.ui.testgen/src/main/java/de/uka/ilkd/key/gui/testgen/TestgenExtension.java b/keyext.ui.testgen/src/main/java/de/uka/ilkd/key/gui/testgen/TestgenExtension.java index f6ed1a4eb56..0f026308e17 100644 --- a/keyext.ui.testgen/src/main/java/de/uka/ilkd/key/gui/testgen/TestgenExtension.java +++ b/keyext.ui.testgen/src/main/java/de/uka/ilkd/key/gui/testgen/TestgenExtension.java @@ -5,7 +5,7 @@ import java.util.Collection; import java.util.Collections; import java.util.List; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; import javax.swing.*; import de.uka.ilkd.key.core.KeYMediator; @@ -35,7 +35,7 @@ private void init(MainWindow window) { } @Override - public @Nonnull List getMainMenuActions(@Nonnull MainWindow mainWindow) { + public @NonNull List getMainMenuActions(@NonNull MainWindow mainWindow) { init(mainWindow); return Arrays.asList(actionCounterExample, actionTestGeneration); } @@ -53,7 +53,7 @@ public void init(MainWindow window, KeYMediator mediator) { } @Override - public @Nonnull JToolBar getToolbar(MainWindow mainWindow) { + public @NonNull JToolBar getToolbar(MainWindow mainWindow) { JToolBar tb = new JToolBar("test generation"); tb.add(actionCounterExample); tb.add(actionTestGeneration); diff --git a/recoder/src/test/java/recoder/testsuite/basic/BasicTestsSuite.java b/recoder/src/test/java/recoder/testsuite/basic/BasicTestsSuite.java index b4b4b021259..d77332c17c7 100644 --- a/recoder/src/test/java/recoder/testsuite/basic/BasicTestsSuite.java +++ b/recoder/src/test/java/recoder/testsuite/basic/BasicTestsSuite.java @@ -3,7 +3,7 @@ package recoder.testsuite.basic; import java.io.File; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; import recoder.CrossReferenceServiceConfiguration; import recoder.service.DefaultErrorHandler; @@ -17,7 +17,7 @@ public class BasicTestsSuite { private static CrossReferenceServiceConfiguration config; private static File projectFile; - @Nonnull + @NonNull public static File getProjectFile() { if (projectFile == null) { init(); @@ -25,7 +25,7 @@ public static File getProjectFile() { return projectFile; } - @Nonnull + @NonNull public static CrossReferenceServiceConfiguration getConfig() { if (config == null) { init(); diff --git a/settings.gradle b/settings.gradle index 12b3d123ece..8547dff730e 100644 --- a/settings.gradle +++ b/settings.gradle @@ -13,3 +13,6 @@ include 'recoder' include 'keyext.ui.testgen' include 'keyext.exploration' include 'keyext.slicing' + +// ENABLE NULLNESS here or on the CLI +// System.setProperty("ENABLE_NULLNESS", "true") \ No newline at end of file From 69a19d5bc119e6c3fb2f1613a0c8c5310334f7b7 Mon Sep 17 00:00:00 2001 From: Alexander Weigl Date: Fri, 21 Jul 2023 18:32:23 +0200 Subject: [PATCH 19/37] some more annotations --- .../uka/ilkd/key/nparser/ParsingFacade.java | 10 +- .../nparser/builder/ExpressionBuilder.java | 2 +- .../java/de/uka/ilkd/key/proof/Proof.java | 161 +++++++++++------- .../ilkd/key/proof/mgt/ProofEnvironment.java | 1 + .../uka/ilkd/key/proof/mgt/package-info.java | 9 + .../de/uka/ilkd/key/proof/mgt/package.html | 15 -- .../TextualJMLMergePointDecl.java | 13 +- .../de/uka/ilkd/key/util/KeYTypeUtil.java | 9 +- .../de/uka/ilkd/key/util/package-info.java | 7 + .../java/de/uka/ilkd/key/util/package.html | 12 -- .../ilkd/key/gui/extension/api/TabPanel.java | 2 +- settings.gradle | 2 +- 12 files changed, 141 insertions(+), 102 deletions(-) create mode 100644 key.core/src/main/java/de/uka/ilkd/key/proof/mgt/package-info.java delete mode 100644 key.core/src/main/java/de/uka/ilkd/key/proof/mgt/package.html create mode 100644 key.core/src/main/java/de/uka/ilkd/key/util/package-info.java delete mode 100644 key.core/src/main/java/de/uka/ilkd/key/util/package.html diff --git a/key.core/src/main/java/de/uka/ilkd/key/nparser/ParsingFacade.java b/key.core/src/main/java/de/uka/ilkd/key/nparser/ParsingFacade.java index a079ee69e62..6d43b27f8c5 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/nparser/ParsingFacade.java +++ b/key.core/src/main/java/de/uka/ilkd/key/nparser/ParsingFacade.java @@ -11,6 +11,7 @@ import java.nio.file.Path; import java.util.*; import org.jspecify.annotations.NonNull; +import org.jspecify.annotations.NullMarked; import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.nparser.builder.ChoiceFinder; @@ -32,6 +33,7 @@ * @author Alexander Weigl * @version 1 (19.08.19) */ +@NullMarked public final class ParsingFacade { private static final Logger LOGGER = LoggerFactory.getLogger(ParsingFacade.class); @@ -47,8 +49,7 @@ private ParsingFacade() { * @param parse tree type * @return the {@link ParserRuleContext} inside the given ast object. */ - @NonNull - public static T getParseRuleContext(@NonNull KeyAst ast) { + public static T getParseRuleContext(KeyAst ast) { return ast.ctx; } @@ -78,7 +79,7 @@ public static List parseFiles(URL url) throws IOException { * * @param ctxs non-null list */ - public static @NonNull ChoiceInformation getChoices(@NonNull List ctxs) { + public static ChoiceInformation getChoices(List ctxs) { ChoiceInformation ci = new ChoiceInformation(); ChoiceFinder finder = new ChoiceFinder(ci); ctxs.forEach(it -> it.accept(finder)); @@ -162,8 +163,7 @@ public static KeyAst.Seq parseSequent(CharStream stream) { * @param ctx non-null context * @return non-null string */ - public static @NonNull String getValueDocumentation( - @NonNull KeYParser.String_valueContext ctx) { + public static String getValueDocumentation(KeYParser.String_valueContext ctx) { return ctx.getText().substring(1, ctx.getText().length() - 1).replace("\\\"", "\"") .replace("\\\\", "\\"); } diff --git a/key.core/src/main/java/de/uka/ilkd/key/nparser/builder/ExpressionBuilder.java b/key.core/src/main/java/de/uka/ilkd/key/nparser/builder/ExpressionBuilder.java index e35c1307f28..1fbf533eeaf 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/nparser/builder/ExpressionBuilder.java +++ b/key.core/src/main/java/de/uka/ilkd/key/nparser/builder/ExpressionBuilder.java @@ -1550,7 +1550,7 @@ public Term visitAccessterm(KeYParser.AccesstermContext ctx) { return current; } - private @Nullable Term[] visitArguments(@Nullable KeYParser.Argument_listContext call) { + private @Nullable Term[] visitArguments(KeYParser. @Nullable Argument_listContext call) { List arguments = accept(call); return arguments == null ? null : arguments.toArray(new Term[0]); } diff --git a/key.core/src/main/java/de/uka/ilkd/key/proof/Proof.java b/key.core/src/main/java/de/uka/ilkd/key/proof/Proof.java index 8d21a46fa29..c293de20621 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/proof/Proof.java +++ b/key.core/src/main/java/de/uka/ilkd/key/proof/Proof.java @@ -6,6 +6,7 @@ import java.util.*; import java.util.function.Predicate; import org.jspecify.annotations.NonNull; +import org.jspecify.annotations.NullMarked; import org.jspecify.annotations.Nullable; import javax.swing.*; @@ -48,6 +49,7 @@ * information, and methods to apply rules. Furthermore, it offers services that deliver the open * goals, namespaces and several other information about the current state of the proof. */ +@NullMarked public class Proof implements Named { /** @@ -55,10 +57,14 @@ public class Proof implements Named { */ final long creationTime = System.currentTimeMillis(); - /** name of the proof */ + /** + * name of the proof + */ private final Name name; - /** the root of the proof */ + /** + * the root of the proof + */ private Node root; /** @@ -67,7 +73,9 @@ public class Proof implements Named { */ private final List listenerList = new LinkedList<>(); - /** list with the open goals of the proof */ + /** + * list with the open goals of the proof + */ private ImmutableList openGoals = ImmutableSLList.nil(); /** @@ -77,22 +85,35 @@ public class Proof implements Named { */ private ImmutableList closedGoals = ImmutableSLList.nil(); - /** declarations &c, read from a problem file or otherwise */ + /** + * declarations &c, read from a problem file or otherwise + */ private String problemHeader = ""; - /** the proof environment (optional) */ + /** + * the proof environment (optional) + */ + @Nullable private ProofEnvironment env; - /** maps the Abbreviations valid for this proof to their corresponding terms. */ + /** + * maps the Abbreviations valid for this proof to their corresponding terms. + */ private AbbrevMap abbreviations = new AbbrevMap(); - /** the logic configuration for this proof, i.e., logic signature, rules etc. */ + /** + * the logic configuration for this proof, i.e., logic signature, rules etc. + */ private InitConfig initConfig; - /** the environment of the proof with specs and java model */ + /** + * the environment of the proof with specs and java model + */ private ProofCorrectnessMgt localMgt; - /** settings valid independent of a proof */ + /** + * settings valid independent of a proof + */ private final ProofIndependentSettings pis; /** * when different users load and save a proof this vector fills up with Strings containing the @@ -108,6 +129,7 @@ public class Proof implements Named { private long autoModeTime = 0; + @Nullable private Strategy activeStrategy; private PropertyChangeListener settingsListener; @@ -118,9 +140,11 @@ public class Proof implements Named { */ private boolean disposed = false; - /** list of rule app listeners */ + /** + * list of rule app listeners + */ private final List ruleAppListenerList = - Collections.synchronizedList(new ArrayList<>(10)); + Collections.synchronizedList(new ArrayList<>(10)); /** * Contains all registered {@link ProofDisposedListener}. */ @@ -130,6 +154,7 @@ public class Proof implements Named { * The {@link File} under which this {@link Proof} was saved the last time if available or * {@code null} otherwise. */ + @Nullable private File proofFile; @Nullable @@ -151,7 +176,7 @@ private Proof(Name name, InitConfig initConfig) { final Services services = this.initConfig.getServices(); services.setProof(this); this.proofFile = - services.getJavaModel() != null ? services.getJavaModel().getInitialFile() : null; + services.getJavaModel() != null ? services.getJavaModel().getInitialFile() : null; settingsListener = config -> updateStrategyOnGoals(); @@ -167,29 +192,30 @@ private Proof(Name name, InitConfig initConfig) { */ private void initStrategy() { StrategyProperties activeStrategyProperties = - initConfig.getSettings().getStrategySettings().getActiveStrategyProperties(); + initConfig.getSettings().getStrategySettings().getActiveStrategyProperties(); final Profile profile = getServices().getProfile(); final Name strategy = initConfig.getSettings().getStrategySettings().getStrategy(); if (profile.supportsStrategyFactory(strategy)) { setActiveStrategy( - profile.getStrategyFactory(strategy).create(this, activeStrategyProperties)); + profile.getStrategyFactory(strategy).create(this, activeStrategyProperties)); } else { setActiveStrategy( - profile.getDefaultStrategyFactory().create(this, activeStrategyProperties)); + profile.getDefaultStrategyFactory().create(this, activeStrategyProperties)); } } - - /** constructs a new empty proof with name */ + /** + * constructs a new empty proof with name + */ public Proof(String name, InitConfig initConfig) { this(new Name(name), initConfig); } private Proof(String name, Sequent problem, TacletIndex rules, BuiltInRuleIndex builtInRules, - InitConfig initConfig) { + InitConfig initConfig) { this(new Name(name), initConfig); if (!ProofIndependentSettings.DEFAULT_INSTANCE.getTermLabelSettings() @@ -203,7 +229,7 @@ private Proof(String name, Sequent problem, TacletIndex rules, BuiltInRuleIndex rootNode.sequent().forEach(formula -> { OriginTermLabel originLabel = - (OriginTermLabel) formula.formula().getLabel(OriginTermLabel.NAME); + (OriginTermLabel) formula.formula().getLabel(OriginTermLabel.NAME); if (originLabel != null) { if (originLabel.getOrigin() instanceof FileOrigin) { ((FileOrigin) originLabel.getOrigin()) @@ -219,7 +245,7 @@ private Proof(String name, Sequent problem, TacletIndex rules, BuiltInRuleIndex }); var firstGoal = - new Goal(rootNode, rules, new BuiltInRuleAppIndex(builtInRules), getServices()); + new Goal(rootNode, rules, new BuiltInRuleAppIndex(builtInRules), getServices()); openGoals = openGoals.prepend(firstGoal); setRoot(rootNode); @@ -230,15 +256,15 @@ private Proof(String name, Sequent problem, TacletIndex rules, BuiltInRuleIndex public Proof(String name, Term problem, String header, InitConfig initConfig) { this(name, - Sequent.createSuccSequent( - Semisequent.EMPTY_SEMISEQUENT.insert(0, new SequentFormula(problem)).semisequent()), - initConfig.createTacletIndex(), initConfig.createBuiltInRuleIndex(), initConfig); + Sequent.createSuccSequent( + Semisequent.EMPTY_SEMISEQUENT.insert(0, new SequentFormula(problem)).semisequent()), + initConfig.createTacletIndex(), initConfig.createBuiltInRuleIndex(), initConfig); problemHeader = header; } public Proof(String name, Sequent sequent, String header, TacletIndex rules, - BuiltInRuleIndex builtInRules, InitConfig initConfig) { + BuiltInRuleIndex builtInRules, InitConfig initConfig) { this(name, sequent, rules, builtInRules, initConfig); problemHeader = header; } @@ -261,7 +287,7 @@ public void dispose() { } if (localMgt != null) { localMgt.removeProofListener(); // This is strongly required because the listener is - // contained in a static List + // contained in a static List } // remove setting listener from settings initConfig.getSettings().getStrategySettings() @@ -323,12 +349,16 @@ public NamespaceSet getNamespaces() { return getServices().getNamespaces(); } - /** returns the JavaInfo with the java type information */ + /** + * returns the JavaInfo with the java type information + */ public JavaInfo getJavaInfo() { return getServices().getJavaInfo(); } - /** returns the Services with the java service classes */ + /** + * returns the Services with the java service classes + */ public Services getServices() { return initConfig.getServices(); } @@ -342,8 +372,9 @@ public void addAutoModeTime(long time) { } - - /** sets the variable, function, sort, heuristics namespaces */ + /** + * sets the variable, function, sort, heuristics namespaces + */ public void setNamespaces(NamespaceSet ns) { getServices().setNamespaces(ns); if (!root.leaf()) { @@ -412,7 +443,9 @@ public Node root() { } - /** sets the root of the proof */ + /** + * sets the root of the proof + */ public void setRoot(Node root) { if (this.root != null) { throw new IllegalStateException("Tried to reset the root of the proof."); @@ -455,7 +488,6 @@ public ImmutableList closedGoals() { * Returns the list of all, open and closed, goals. * * @return list with all goals. - * * @see #openGoals() * @see #closedGoals() */ @@ -480,8 +512,8 @@ public ImmutableList openEnabledGoals() { * * @param goals non-null list of goals * @return sublist such that every goal in the list is enabled - * @see Goal#isAutomatic() * @author mulbrich + * @see Goal#isAutomatic() */ private ImmutableList filterEnabledGoals(ImmutableList goals) { ImmutableList enabledGoals = ImmutableSLList.nil(); @@ -497,9 +529,9 @@ private ImmutableList filterEnabledGoals(ImmutableList goals) { /** * removes the given goal and adds the new goals in list * - * @param oldGoal the old goal that has to be removed from list + * @param oldGoal the old goal that has to be removed from list * @param newGoals the IList with the new goals that were result of a rule application on - * goal + * goal */ public void replace(Goal oldGoal, ImmutableList newGoals) { openGoals = openGoals.removeAll(oldGoal); @@ -548,7 +580,7 @@ public void closeGoal(Goal goalToClose) { /** * Opens a previously closed node (the one corresponding to p_goal) and all its closed parents. *

- * + *

* This is, for instance, needed for the {@link MergeRule}: In a situation where a merge node * and its associated partners have been closed and the merge node is then pruned away, the * partners have to be reopened again. Otherwise, we have a soundness issue. @@ -681,7 +713,7 @@ public ImmutableList prune(final Node cuttingPoint) { // Merge rule applications: Unlink all merge partners. if (visitedNode.getAppliedRuleApp() instanceof MergeRuleBuiltInRuleApp) { final MergeRuleBuiltInRuleApp mergeApp = - (MergeRuleBuiltInRuleApp) visitedNode.getAppliedRuleApp(); + (MergeRuleBuiltInRuleApp) visitedNode.getAppliedRuleApp(); for (MergePartner mergePartner : mergeApp.getMergePartners()) { final Goal linkedGoal = mergePartner.getGoal(); @@ -701,7 +733,7 @@ public ImmutableList prune(final Node cuttingPoint) { // first leaf is closed -> add as goal and reopen final Goal firstGoal = - firstLeaf.isClosed() ? getClosedGoal(firstLeaf) : getGoal(firstLeaf); + firstLeaf.isClosed() ? getClosedGoal(firstLeaf) : getGoal(firstLeaf); assert firstGoal != null; if (firstLeaf.isClosed()) { add(firstGoal); @@ -727,7 +759,7 @@ public ImmutableList prune(final Node cuttingPoint) { firstGoal.pruneToParent(); final List undoMethods = - visitedNode.getStrategyInfoUndoMethods(); + visitedNode.getStrategyInfoUndoMethods(); for (StrategyInfoUndoMethod undoMethod : undoMethods) { firstGoal.undoStrategyInfoAdd(undoMethod); } @@ -907,7 +939,9 @@ public void traverseFromChildToParent(Node child, Node parent, ProofVisitor visi } while (child != parent); } - /** fires the event that the proof has been expanded at the given node */ + /** + * fires the event that the proof has been expanded at the given node + */ public void fireProofExpanded(Node node) { ProofTreeEvent e = new ProofTreeEvent(this, node); synchronized (listenerList) { @@ -917,7 +951,9 @@ public void fireProofExpanded(Node node) { } } - /** fires the event that the proof is being pruned at the given node */ + /** + * fires the event that the proof is being pruned at the given node + */ protected void fireProofIsBeingPruned(Node below) { ProofTreeEvent e = new ProofTreeEvent(this, below); synchronized (listenerList) { @@ -927,7 +963,9 @@ protected void fireProofIsBeingPruned(Node below) { } } - /** fires the event that the proof has been pruned at the given node */ + /** + * fires the event that the proof has been pruned at the given node + */ protected void fireProofPruned(Node below) { ProofTreeEvent e = new ProofTreeEvent(this, below); synchronized (listenerList) { @@ -938,7 +976,9 @@ protected void fireProofPruned(Node below) { } - /** fires the event that the proof has been restructured */ + /** + * fires the event that the proof has been restructured + */ public void fireProofStructureChanged() { ProofTreeEvent e = new ProofTreeEvent(this); synchronized (listenerList) { @@ -949,7 +989,9 @@ public void fireProofStructureChanged() { } - /** fires the event that a goal has been removed from the list of goals */ + /** + * fires the event that a goal has been removed from the list of goals + */ protected void fireProofGoalRemoved(Goal goal) { ProofTreeEvent e = new ProofTreeEvent(this, goal); synchronized (listenerList) { @@ -981,7 +1023,9 @@ protected void fireProofGoalsAdded(Goal goal) { } - /** fires the event that the proof has been restructured */ + /** + * fires the event that the proof has been restructured + */ public void fireProofGoalsChanged() { ProofTreeEvent e = new ProofTreeEvent(this, openGoals()); synchronized (listenerList) { @@ -1078,7 +1122,7 @@ public Goal getGoal(Node node) { /** * @param node the Node which is checked for a corresponding closed goal * @return true if the goal that belongs to the given node is closed and false if not or if - * there is no such goal. + * there is no such goal. */ public boolean isClosedGoal(Node node) { return getClosedGoal(node) != null; @@ -1089,7 +1133,7 @@ public boolean isClosedGoal(Node node) { * * @param node the Node where a corresponding closed goal is searched * @return the closed goal that belongs to the given node or null if the node is an inner one or - * an open goal + * an open goal */ public Goal getClosedGoal(Node node) { for (final Goal result : closedGoals) { @@ -1125,7 +1169,7 @@ public ImmutableList getClosedSubtreeGoals(Node node) { * Returns a list of all goals from the provided list that are associated to goals below * node * - * @param node the root of the subtree + * @param node the root of the subtree * @param fromGoals the list of goals from which to select * @return the goals below node that are contained in fromGoals */ @@ -1207,7 +1251,9 @@ public Statistics getStatistics() { return new Statistics(this); } - /** toString */ + /** + * toString + */ @Override public String toString() { StringBuilder result = new StringBuilder(); @@ -1226,7 +1272,9 @@ public String toString() { return result.toString(); } - /** fires the event that a rule has been applied */ + /** + * fires the event that a rule has been applied + */ protected void fireRuleApplied(ProofEvent p_e) { synchronized (ruleAppListenerList) { for (RuleAppListener ral : ruleAppListenerList) { @@ -1316,7 +1364,7 @@ public InitConfig getInitConfig() { * Returns the {@link File} under which the {@link Proof} was saved the last time if available. * * @return The {@link File} under which the {@link Proof} was saved the last time or - * {@code null} if not available. + * {@code null} if not available. */ public File getProofFile() { return proofFile; @@ -1349,9 +1397,8 @@ public void saveProofObligationToFile(File file) throws IOException { } /** - * * @return the current profile's factory for the active strategy, or the default factory if - * there is no active strategy. + * there is no active strategy. * @see Profile#getStrategyFactory(Name) * @see #getActiveStrategy() */ @@ -1367,7 +1414,7 @@ public StrategyFactory getActiveStrategyFactory() { * Retrieves a user-defined data. * * @param service the class for which the data were registered - * @param any class + * @param any class * @return null or the previous data * @see #register(Object, Class) */ @@ -1385,9 +1432,9 @@ public T lookup(Class service) { /** * Register a user-defined data in this node info. * - * @param obj an object to be registered + * @param obj an object to be registered * @param service the key under it should be registered - * @param type of the object to register + * @param type of the object to register */ public void register(T obj, Class service) { getUserData().register(obj, service); @@ -1396,9 +1443,9 @@ public void register(T obj, Class service) { /** * Remove a previous registered user-defined data. * - * @param obj registered object + * @param obj registered object * @param service the key under which the data was registered - * @param type of the object to unregister + * @param type of the object to unregister */ public void deregister(T obj, Class service) { if (userData != null) { diff --git a/key.core/src/main/java/de/uka/ilkd/key/proof/mgt/ProofEnvironment.java b/key.core/src/main/java/de/uka/ilkd/key/proof/mgt/ProofEnvironment.java index e982bddbb0b..466a132e09f 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/proof/mgt/ProofEnvironment.java +++ b/key.core/src/main/java/de/uka/ilkd/key/proof/mgt/ProofEnvironment.java @@ -11,6 +11,7 @@ import de.uka.ilkd.key.proof.ProofAggregate; import de.uka.ilkd.key.proof.init.InitConfig; import de.uka.ilkd.key.proof.init.ProofOblInput; +import org.jspecify.annotations.NullMarked; /** * The unique environment a proof is performed in. The environment consists of a java model, diff --git a/key.core/src/main/java/de/uka/ilkd/key/proof/mgt/package-info.java b/key.core/src/main/java/de/uka/ilkd/key/proof/mgt/package-info.java new file mode 100644 index 00000000000..ecba0060431 --- /dev/null +++ b/key.core/src/main/java/de/uka/ilkd/key/proof/mgt/package-info.java @@ -0,0 +1,9 @@ +/** + * This package contains classes for proof environments and proof management. For + * example, proof management ensures that contract applications cannot lead to + * unsound cyclic dependencies between proofs. + */ +@NullMarked +package de.uka.ilkd.key.proof.mgt; + +import org.jspecify.annotations.NullMarked; \ No newline at end of file diff --git a/key.core/src/main/java/de/uka/ilkd/key/proof/mgt/package.html b/key.core/src/main/java/de/uka/ilkd/key/proof/mgt/package.html deleted file mode 100644 index 34cebdc1c0b..00000000000 --- a/key.core/src/main/java/de/uka/ilkd/key/proof/mgt/package.html +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - -This package contains classes for proof environments and proof management. For -example, proof management ensures that contract applications cannot lead to -unsound cyclic dependencies between proofs. - - \ No newline at end of file diff --git a/key.core/src/main/java/de/uka/ilkd/key/speclang/jml/pretranslation/TextualJMLMergePointDecl.java b/key.core/src/main/java/de/uka/ilkd/key/speclang/jml/pretranslation/TextualJMLMergePointDecl.java index 8092e3abd2f..cce15f09cf2 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/speclang/jml/pretranslation/TextualJMLMergePointDecl.java +++ b/key.core/src/main/java/de/uka/ilkd/key/speclang/jml/pretranslation/TextualJMLMergePointDecl.java @@ -5,33 +5,34 @@ import de.uka.ilkd.key.speclang.njml.JmlParser; +import org.jspecify.annotations.NullMarked; import org.key_project.util.collection.ImmutableList; /** * A JML merge point declaration in textual form. - * + *

* TODO: Adapt this to the specific needs of merge point declarations. * * @author Dominic Scheurer */ +@NullMarked public final class TextualJMLMergePointDecl extends TextualJMLConstruct { - private final @NonNull JmlParser.Merge_point_statementContext mergeProc; + private final JmlParser.Merge_point_statementContext mergeProc; - public TextualJMLMergePointDecl(@NonNull ImmutableList mods, - @NonNull JmlParser.Merge_point_statementContext mergeProc) { + public TextualJMLMergePointDecl(ImmutableList mods, JmlParser.Merge_point_statementContext mergeProc) { super(mods); this.mergeProc = mergeProc; setPosition(mergeProc); } - public @NonNull JmlParser.Merge_point_statementContext getMergeProc() { + public JmlParser.Merge_point_statementContext getMergeProc() { return mergeProc; } @Override public String toString() { return "TextualJMLMergePointDecl{" + "mergeProc=" + mergeProc.getText() + ", mods=" + mods - + ", name='" + name + '\'' + '}'; + + ", name='" + name + '\'' + '}'; } @Override diff --git a/key.core/src/main/java/de/uka/ilkd/key/util/KeYTypeUtil.java b/key.core/src/main/java/de/uka/ilkd/key/util/KeYTypeUtil.java index 080e0b9c26e..27704594b84 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/util/KeYTypeUtil.java +++ b/key.core/src/main/java/de/uka/ilkd/key/util/KeYTypeUtil.java @@ -12,6 +12,7 @@ import de.uka.ilkd.key.java.reference.TypeReference; import de.uka.ilkd.key.logic.op.IProgramMethod; +import org.jspecify.annotations.Nullable; import org.key_project.util.collection.ImmutableList; import org.key_project.util.java.CollectionUtil; @@ -56,7 +57,7 @@ public static boolean isInnerType(Services services, KeYJavaType type) { * @param type The type. * @return The parent package/type or {@code null} if it has no one. */ - public static String getParentName(Services services, KeYJavaType type) { + public static @Nullable String getParentName(Services services, @Nullable KeYJavaType type) { return type != null ? getParentName(services, type.getFullName()) : null; } @@ -67,7 +68,7 @@ public static String getParentName(Services services, KeYJavaType type) { * @param fullName The name of the current package/type. * @return The parent package/type or {@code null} if it has no one. */ - private static String getParentName(Services services, String fullName) { + private static @Nullable String getParentName(Services services, String fullName) { int lastSeparator = fullName.lastIndexOf(PACKAGE_SEPARATOR); if (lastSeparator >= 0) { String parentName = fullName.substring(0, lastSeparator); @@ -103,7 +104,7 @@ public static boolean isType(Services services, String fullName) { * @param fullName The full name of the requested {@link KeYJavaType}. * @return The found {@link KeYJavaType} or {@code null} if no type exist with the given name. */ - public static KeYJavaType getType(Services services, String fullName) { + public static @Nullable KeYJavaType getType(Services services, String fullName) { try { return services.getJavaInfo().getKeYJavaType(fullName); } catch (Exception e) { @@ -142,7 +143,7 @@ public static boolean isImplicitConstructor(IProgramMethod pm) { * @param implicitConstructor The implicit constructor. * @return The found explicit constructor or {@code null} if not available. */ - public static IProgramMethod findExplicitConstructor(Services services, + public static @Nullable IProgramMethod findExplicitConstructor(Services services, final IProgramMethod implicitConstructor) { if (services != null && implicitConstructor != null) { ImmutableList pms = diff --git a/key.core/src/main/java/de/uka/ilkd/key/util/package-info.java b/key.core/src/main/java/de/uka/ilkd/key/util/package-info.java new file mode 100644 index 00000000000..1391087ae16 --- /dev/null +++ b/key.core/src/main/java/de/uka/ilkd/key/util/package-info.java @@ -0,0 +1,7 @@ +/** + * This package is a grab bag of miscellaneous useful code fragments. + */ +@NullMarked +package de.uka.ilkd.key.util; + +import org.jspecify.annotations.NullMarked; \ No newline at end of file diff --git a/key.core/src/main/java/de/uka/ilkd/key/util/package.html b/key.core/src/main/java/de/uka/ilkd/key/util/package.html deleted file mode 100644 index 910f9a59c9b..00000000000 --- a/key.core/src/main/java/de/uka/ilkd/key/util/package.html +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - This package is a grab bag of miscellaneous useful code fragments. It also contains - side functionalities like the installer (subpackage install), and the tool for - removing generics from a Java program (subpackage removegenerics). - - diff --git a/key.ui/src/main/java/de/uka/ilkd/key/gui/extension/api/TabPanel.java b/key.ui/src/main/java/de/uka/ilkd/key/gui/extension/api/TabPanel.java index c64a28382fc..5b9f3b5dbef 100644 --- a/key.ui/src/main/java/de/uka/ilkd/key/gui/extension/api/TabPanel.java +++ b/key.ui/src/main/java/de/uka/ilkd/key/gui/extension/api/TabPanel.java @@ -38,7 +38,7 @@ public interface TabPanel { return Collections.emptyList(); } - default @Nullable DefaultCDockable.Permissions getPermissions() { + default DefaultCDockable.@Nullable Permissions getPermissions() { return null; } } diff --git a/settings.gradle b/settings.gradle index 8547dff730e..04ba06014e8 100644 --- a/settings.gradle +++ b/settings.gradle @@ -15,4 +15,4 @@ include 'keyext.exploration' include 'keyext.slicing' // ENABLE NULLNESS here or on the CLI -// System.setProperty("ENABLE_NULLNESS", "true") \ No newline at end of file +System.setProperty("ENABLE_NULLNESS", "true") \ No newline at end of file From 17fa5b06fa436e3cc24847cdb044f6e3debd2b18 Mon Sep 17 00:00:00 2001 From: Alexander Weigl Date: Mon, 24 Jul 2023 19:16:08 +0200 Subject: [PATCH 20/37] pushing further --- .../java/org/key_project/util/RandomName.java | 2 - .../java/org/key_project/util/Streams.java | 2 - .../util/collection/Immutables.java | 1 - .../util/collection/KeYCollections.java | 15 +++--- .../util/collection/NotUniqueException.java | 5 +- .../util/collection/package-info.java | 8 ++++ .../util/helper/FindResources.java | 48 +++++++++++-------- .../key_project/util/helper/package-info.java | 7 +++ .../org/key_project/util/java/ArrayUtil.java | 1 - .../key_project/util/java/CollectionUtil.java | 11 +++-- .../org/key_project/util/java/IOUtil.java | 1 - .../key_project/util/java/IntegerUtil.java | 1 - .../org/key_project/util/java/NumberUtil.java | 1 - .../org/key_project/util/java/StringUtil.java | 1 - .../org/key_project/util/java/WrapUtils.java | 1 - .../org/key_project/util/java/XMLUtil.java | 1 - .../key_project/util/java/package-info.java | 7 +++ .../util/java/thread/package-info.java | 7 +++ .../org/key_project/util/package-info.java | 7 +++ .../util/testcategories/Interactive.java | 2 +- .../key_project/util/testcategories/Slow.java | 2 +- .../util/testcategories/package-info.java | 3 ++ 22 files changed, 86 insertions(+), 48 deletions(-) create mode 100644 key.util/src/main/java/org/key_project/util/collection/package-info.java create mode 100644 key.util/src/main/java/org/key_project/util/helper/package-info.java create mode 100644 key.util/src/main/java/org/key_project/util/java/package-info.java create mode 100644 key.util/src/main/java/org/key_project/util/java/thread/package-info.java create mode 100644 key.util/src/main/java/org/key_project/util/package-info.java diff --git a/key.util/src/main/java/org/key_project/util/RandomName.java b/key.util/src/main/java/org/key_project/util/RandomName.java index 06788533359..209e27af247 100644 --- a/key.util/src/main/java/org/key_project/util/RandomName.java +++ b/key.util/src/main/java/org/key_project/util/RandomName.java @@ -8,8 +8,6 @@ * @author Alexander Weigl * @version 1 (06.12.18) */ - -@NullMarked public class RandomName { private static final Random random = new Random(); diff --git a/key.util/src/main/java/org/key_project/util/Streams.java b/key.util/src/main/java/org/key_project/util/Streams.java index b10f298b2b2..7acc077912c 100644 --- a/key.util/src/main/java/org/key_project/util/Streams.java +++ b/key.util/src/main/java/org/key_project/util/Streams.java @@ -4,9 +4,7 @@ import java.io.IOException; import java.io.InputStream; -@SuppressWarnings("nullness") public class Streams { - private Streams() { throw new Error("do not instantiate"); } diff --git a/key.util/src/main/java/org/key_project/util/collection/Immutables.java b/key.util/src/main/java/org/key_project/util/collection/Immutables.java index a88cf9acb00..2a214e3799e 100644 --- a/key.util/src/main/java/org/key_project/util/collection/Immutables.java +++ b/key.util/src/main/java/org/key_project/util/collection/Immutables.java @@ -15,7 +15,6 @@ * * @author Mattias Ulbrich */ -@NullMarked public final class Immutables { private Immutables() { diff --git a/key.util/src/main/java/org/key_project/util/collection/KeYCollections.java b/key.util/src/main/java/org/key_project/util/collection/KeYCollections.java index 11d479a6f91..7edc8398df2 100644 --- a/key.util/src/main/java/org/key_project/util/collection/KeYCollections.java +++ b/key.util/src/main/java/org/key_project/util/collection/KeYCollections.java @@ -1,5 +1,7 @@ package org.key_project.util.collection; +import org.jspecify.annotations.Nullable; + import java.util.Arrays; import java.util.HashMap; import java.util.Map; @@ -10,11 +12,9 @@ /** * Utilities for Collections. * - * * @author Alexander Weigl * @version 1 (29.03.19) */ -@SuppressWarnings("nullness") public class KeYCollections { // ======================================================= // Methods operating on Arrays @@ -24,7 +24,7 @@ public class KeYCollections { * Concatenates two arrays. The second array may have an entry type that is a subtype of the * first one. */ - public static S[] concat(S[] s1, T[] s2) { + public static S[] concat(S[] s1, T[] s2) { S[] res = Arrays.copyOf(s1, s1.length + s2.length); System.arraycopy(s2, 0, res, s1.length, s2.length); return res; @@ -56,9 +56,12 @@ public static Map apply(Map m0, Map m1) { } for (Map.Entry e : m0.entrySet()) { - final U value = m1.get(e.getValue()); - if (value != null) { - res.put(e.getKey(), value); + final T v1 = e.getValue(); + if (v1 != null) { + final U value = m1.get(v1); + if (value != null) { + res.put(e.getKey(), value); + } } } return res; diff --git a/key.util/src/main/java/org/key_project/util/collection/NotUniqueException.java b/key.util/src/main/java/org/key_project/util/collection/NotUniqueException.java index d4bcb3755b4..50b31ce9cdf 100644 --- a/key.util/src/main/java/org/key_project/util/collection/NotUniqueException.java +++ b/key.util/src/main/java/org/key_project/util/collection/NotUniqueException.java @@ -4,11 +4,8 @@ import org.jspecify.annotations.Nullable; /** thrown if a duplicate is being added via addUnique() */ -@SuppressWarnings("nullness") public class NotUniqueException extends Exception { - - private static final long serialVersionUID = 6565515240836947955L; - final @Nullable Object offender; + private final @Nullable Object offender; public NotUniqueException(@Nullable Object o) { offender = o; diff --git a/key.util/src/main/java/org/key_project/util/collection/package-info.java b/key.util/src/main/java/org/key_project/util/collection/package-info.java new file mode 100644 index 00000000000..e782219bb9e --- /dev/null +++ b/key.util/src/main/java/org/key_project/util/collection/package-info.java @@ -0,0 +1,8 @@ +/** + * @author Alexander Weigl + * @version 1 (24.07.23) + */ +@NullMarked +package org.key_project.util.collection; + +import org.jspecify.annotations.NullMarked; \ No newline at end of file diff --git a/key.util/src/main/java/org/key_project/util/helper/FindResources.java b/key.util/src/main/java/org/key_project/util/helper/FindResources.java index a2365f38712..5bd131024df 100644 --- a/key.util/src/main/java/org/key_project/util/helper/FindResources.java +++ b/key.util/src/main/java/org/key_project/util/helper/FindResources.java @@ -1,5 +1,9 @@ package org.key_project.util.helper; +import org.checkerframework.checker.units.qual.N; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; + import java.io.File; import java.io.IOException; import java.net.URISyntaxException; @@ -14,7 +18,6 @@ * @author Alexander Weigl * @version 1 (13.02.19) */ -@SuppressWarnings("nullness") public final class FindResources { /** * List directory contents for a resource folder. Not recursive. This is basically a brute-force @@ -27,13 +30,18 @@ public final class FindResources { * @throws IOException * @author Greg Briggs */ - public static List getResources(String path, Class clazz) + public static @Nullable List getResources(String path, Class clazz) throws URISyntaxException, IOException { - URL dirURL = clazz.getClassLoader().getResource(path); + final var classLoader = clazz.getClassLoader(); + + if (classLoader == null) return null; + + @Nullable URL dirURL = classLoader.getResource(path); if (dirURL != null && dirURL.getProtocol().equals("file")) { /* A file path: easy enough */ File[] files = new File(dirURL.toURI()).listFiles(); - Objects.requireNonNull(files); + if(files == null) + files = new File[0]; return Arrays.stream(files).map(File::toPath).collect(Collectors.toList()); } @@ -43,7 +51,7 @@ public static List getResources(String path, Class clazz) * jar as clazz. */ String me = clazz.getName().replace(".", "/") + ".class"; - dirURL = clazz.getClassLoader().getResource(me); + dirURL = classLoader.getResource(me); } if (dirURL == null) { @@ -55,7 +63,7 @@ public static List getResources(String path, Class clazz) // strip out only the JAR file String jarPath = dirURL.getPath().substring(5, dirURL.getPath().indexOf('!')); try (FileSystem fs = - FileSystems.newFileSystem(Paths.get(jarPath), clazz.getClassLoader())) { + FileSystems.newFileSystem(Paths.get(jarPath), classLoader)) { Path dir = fs.getPath(path); try (var s = Files.list(dir)) { return s.collect(Collectors.toList()); @@ -65,13 +73,15 @@ public static List getResources(String path, Class clazz) throw new UnsupportedOperationException("Cannot list files for URL \"" + dirURL + "\""); } - public static List getResources(String path) throws URISyntaxException, IOException { + public static @Nullable List getResources(String path) throws URISyntaxException, IOException { return getResources(path, FindResources.class); } - public static Path getResource(String path, Class clazz) + public static @Nullable Path getResource(String path, Class clazz) throws URISyntaxException, IOException { - URL dirURL = clazz.getClassLoader().getResource(path); + final var classLoader = clazz.getClassLoader(); + if(classLoader == null) return null; + URL dirURL = classLoader.getResource(path); if (dirURL != null && dirURL.getProtocol().equals("file")) { return new File(dirURL.toURI()).toPath(); } @@ -82,7 +92,7 @@ public static Path getResource(String path, Class clazz) * jar as clazz. */ String me = clazz.getName().replace(".", "/") + ".class"; - dirURL = clazz.getClassLoader().getResource(me); + dirURL = classLoader.getResource(me); } if (dirURL == null) { @@ -94,14 +104,14 @@ public static Path getResource(String path, Class clazz) // strip out only the JAR file String jarPath = dirURL.getPath().substring(5, dirURL.getPath().indexOf('!')); try (FileSystem fs = - FileSystems.newFileSystem(Paths.get(jarPath), clazz.getClassLoader())) { + FileSystems.newFileSystem(Paths.get(jarPath), classLoader)) { return fs.getPath(path); } } throw new UnsupportedOperationException("Cannot list files for URL \"" + dirURL + "\""); } - public static Path getResource(String path) throws URISyntaxException, IOException { + public static @Nullable Path getResource(String path) throws URISyntaxException, IOException { return getResource(path, FindResources.class); } @@ -110,7 +120,7 @@ public static Path getResource(String path) throws URISyntaxException, IOExc * @param candidates * @return */ - public static File findFolder(String property, String... candidates) { + public static @Nullable File findFolder(String property, String... candidates) { return findFolder(true, property, candidates); } @@ -129,7 +139,7 @@ public static File findFolder(String property, String... candidates) { * user * @return */ - public static File findFolder(boolean exists, String property, String... candidates) { + public static @Nullable File findFolder(boolean exists, String property, String... candidates) { if (System.getProperty(property) != null) { File f = new File(System.getProperty(property)); if (f.exists() || !exists) { @@ -145,23 +155,23 @@ public static File findFolder(boolean exists, String property, String... candida return null; } - public static File getExampleDirectory() { + public static @Nullable File getExampleDirectory() { return findFolder("KEY_EXAMPLES_DIR", "key.ui/examples", "../key.ui/examples", "examples"); } - public static File getTestResultForRunAllProofs() { + public static @Nullable File getTestResultForRunAllProofs() { return findFolder(false, "KEY_TESTRESULT_RUNALLPROOFS", "build/reports/runallproofs"); } - public static File getTestCasesDirectory() { + public static @Nullable File getTestCasesDirectory() { return findFolder("TEST_CASES", "src/test/resources/testcase"); } - public static File getTestResourcesDirectory() { + public static @Nullable File getTestResourcesDirectory() { return findFolder("TEST_RESOURCES", "src/test/resources/"); } - public static File getTacletProofsDirectory() { + public static @Nullable File getTacletProofsDirectory() { return findFolder("TACLET_PROOFS", "key.core/tacletProofs", "../key.core/tacletProofs", "tacletProofs"); } diff --git a/key.util/src/main/java/org/key_project/util/helper/package-info.java b/key.util/src/main/java/org/key_project/util/helper/package-info.java new file mode 100644 index 00000000000..c9e748024b4 --- /dev/null +++ b/key.util/src/main/java/org/key_project/util/helper/package-info.java @@ -0,0 +1,7 @@ +/** + * @author Alexander Weigl + * @version 1 (24.07.23) + */ +@NullMarked package org.key_project.util.helper; + +import org.jspecify.annotations.NullMarked; \ No newline at end of file diff --git a/key.util/src/main/java/org/key_project/util/java/ArrayUtil.java b/key.util/src/main/java/org/key_project/util/java/ArrayUtil.java index 5c5d780b656..19d4375c154 100644 --- a/key.util/src/main/java/org/key_project/util/java/ArrayUtil.java +++ b/key.util/src/main/java/org/key_project/util/java/ArrayUtil.java @@ -13,7 +13,6 @@ * * @author Martin Hentschel */ -@NullMarked public final class ArrayUtil { /** * Forbid instances by this private constructor. diff --git a/key.util/src/main/java/org/key_project/util/java/CollectionUtil.java b/key.util/src/main/java/org/key_project/util/java/CollectionUtil.java index 82a97084db8..b87c1ef33d0 100644 --- a/key.util/src/main/java/org/key_project/util/java/CollectionUtil.java +++ b/key.util/src/main/java/org/key_project/util/java/CollectionUtil.java @@ -1,5 +1,7 @@ package org.key_project.util.java; +import org.jspecify.annotations.Nullable; + import java.util.*; import java.util.function.Predicate; @@ -8,7 +10,6 @@ * * @author Martin Hentschel */ -@SuppressWarnings("nullness") public class CollectionUtil { /** * The default separator. @@ -171,7 +172,7 @@ public static List searchAll(Iterable iterable, Predicate filter) { * @param filter The filter to select an element. * @return The found element or {@code null} if no element was found. */ - public static T search(Iterable iterable, Predicate filter) { + public static @Nullable T search(Iterable iterable, Predicate filter) { T result = null; if (iterable != null && filter != null) { Iterator iter = iterable.iterator(); @@ -193,7 +194,7 @@ public static T search(Iterable iterable, Predicate filter) { * @param filter The filter to select an element. * @return The found element or {@code null} if no element was found. */ - public static T searchAndRemove(Iterable iterable, Predicate filter) { + public static @Nullable T searchAndRemove(Iterable iterable, Predicate filter) { T result = null; if (iterable != null && filter != null) { Iterator iter = iterable.iterator(); @@ -216,7 +217,7 @@ public static T searchAndRemove(Iterable iterable, Predicate filter) { * @param filter The filter to select an element. * @return The found element or {@code null} if no element was found. */ - public static T searchAndRemoveWithException(Iterable iterable, + public static @Nullable T searchAndRemoveWithException(Iterable iterable, IFilterWithException filter) throws E { T result = null; if (iterable != null && filter != null) { @@ -312,7 +313,7 @@ public static boolean containsSame(Collection first, Collection second * @param iterable The {@link Iterable} to remove first element from. * @return The removed first element or {@code null} if no element was removed. */ - public static T removeFirst(Iterable iterable) { + public static @Nullable T removeFirst(Iterable iterable) { try { if (iterable != null) { Iterator iter = iterable.iterator(); diff --git a/key.util/src/main/java/org/key_project/util/java/IOUtil.java b/key.util/src/main/java/org/key_project/util/java/IOUtil.java index 2d1af385628..da9742a2f62 100644 --- a/key.util/src/main/java/org/key_project/util/java/IOUtil.java +++ b/key.util/src/main/java/org/key_project/util/java/IOUtil.java @@ -23,7 +23,6 @@ * * @author Martin Hentschel */ -@NullMarked public final class IOUtil { /** * The size of used buffers. diff --git a/key.util/src/main/java/org/key_project/util/java/IntegerUtil.java b/key.util/src/main/java/org/key_project/util/java/IntegerUtil.java index 3224fbd28a9..bc2d58ec295 100644 --- a/key.util/src/main/java/org/key_project/util/java/IntegerUtil.java +++ b/key.util/src/main/java/org/key_project/util/java/IntegerUtil.java @@ -2,7 +2,6 @@ import org.jspecify.annotations.NullMarked; -@NullMarked public final class IntegerUtil { /** * Forbid instances. diff --git a/key.util/src/main/java/org/key_project/util/java/NumberUtil.java b/key.util/src/main/java/org/key_project/util/java/NumberUtil.java index 6c5fc2d0002..1ed5fd20d04 100644 --- a/key.util/src/main/java/org/key_project/util/java/NumberUtil.java +++ b/key.util/src/main/java/org/key_project/util/java/NumberUtil.java @@ -7,7 +7,6 @@ * * @author Martin Hentschel */ -@NullMarked public class NumberUtil { /** * The maximal number of digits of an integer value. diff --git a/key.util/src/main/java/org/key_project/util/java/StringUtil.java b/key.util/src/main/java/org/key_project/util/java/StringUtil.java index 33c9b722736..3ac2e544e9e 100644 --- a/key.util/src/main/java/org/key_project/util/java/StringUtil.java +++ b/key.util/src/main/java/org/key_project/util/java/StringUtil.java @@ -18,7 +18,6 @@ * * @author Martin Hentschel */ -@NullMarked public final class StringUtil { /** Pattern for newlines */ private static final Pattern NEWLINE_PATTERN = Pattern.compile("(\\r\\n|\\r|\\n)"); diff --git a/key.util/src/main/java/org/key_project/util/java/WrapUtils.java b/key.util/src/main/java/org/key_project/util/java/WrapUtils.java index 4d0328b5b36..b4f5e6d5fa1 100644 --- a/key.util/src/main/java/org/key_project/util/java/WrapUtils.java +++ b/key.util/src/main/java/org/key_project/util/java/WrapUtils.java @@ -14,7 +14,6 @@ * * @author Mattias Ulbrich, Mar 2021 */ -@NullMarked public class WrapUtils { /* diff --git a/key.util/src/main/java/org/key_project/util/java/XMLUtil.java b/key.util/src/main/java/org/key_project/util/java/XMLUtil.java index f65e3b76afe..5184b7088c2 100644 --- a/key.util/src/main/java/org/key_project/util/java/XMLUtil.java +++ b/key.util/src/main/java/org/key_project/util/java/XMLUtil.java @@ -12,7 +12,6 @@ * * @author Martin Hentschel */ -@NullMarked public final class XMLUtil { /** * Attribute name to store encodings. diff --git a/key.util/src/main/java/org/key_project/util/java/package-info.java b/key.util/src/main/java/org/key_project/util/java/package-info.java new file mode 100644 index 00000000000..d07419ac987 --- /dev/null +++ b/key.util/src/main/java/org/key_project/util/java/package-info.java @@ -0,0 +1,7 @@ +/** + * @author Alexander Weigl + * @version 1 (24.07.23) + */ +@NullMarked package org.key_project.util.java; + +import org.jspecify.annotations.NullMarked; \ No newline at end of file diff --git a/key.util/src/main/java/org/key_project/util/java/thread/package-info.java b/key.util/src/main/java/org/key_project/util/java/thread/package-info.java new file mode 100644 index 00000000000..5d90f9ce6bb --- /dev/null +++ b/key.util/src/main/java/org/key_project/util/java/thread/package-info.java @@ -0,0 +1,7 @@ +/** + * @author Alexander Weigl + * @version 1 (24.07.23) + */ +@NullMarked package org.key_project.util.java.thread; + +import org.jspecify.annotations.NullMarked; \ No newline at end of file diff --git a/key.util/src/main/java/org/key_project/util/package-info.java b/key.util/src/main/java/org/key_project/util/package-info.java new file mode 100644 index 00000000000..7f5c80ce71b --- /dev/null +++ b/key.util/src/main/java/org/key_project/util/package-info.java @@ -0,0 +1,7 @@ +/** + * @author Alexander Weigl + * @version 1 (24.07.23) + */ +@NullMarked package org.key_project.util; + +import org.jspecify.annotations.NullMarked; \ No newline at end of file diff --git a/key.util/src/main/java/org/key_project/util/testcategories/Interactive.java b/key.util/src/main/java/org/key_project/util/testcategories/Interactive.java index 0981e02c2d4..381a63363cf 100644 --- a/key.util/src/main/java/org/key_project/util/testcategories/Interactive.java +++ b/key.util/src/main/java/org/key_project/util/testcategories/Interactive.java @@ -1,7 +1,7 @@ package org.key_project.util.testcategories; /** - * These test should never be executed by CIs, because they require manual interaction. + * CIs should never execute these tests, because they require manual interaction. */ public interface Interactive { } diff --git a/key.util/src/main/java/org/key_project/util/testcategories/Slow.java b/key.util/src/main/java/org/key_project/util/testcategories/Slow.java index 245d0dfe196..e5f100c2049 100644 --- a/key.util/src/main/java/org/key_project/util/testcategories/Slow.java +++ b/key.util/src/main/java/org/key_project/util/testcategories/Slow.java @@ -1,7 +1,7 @@ package org.key_project.util.testcategories; /** - * Category for slow test cases, that should only consider on Jenkins (merge request and master). + * Category for slow test cases, that should only consider on Jenkins (merge request and main). */ public interface Slow { } diff --git a/key.util/src/main/java/org/key_project/util/testcategories/package-info.java b/key.util/src/main/java/org/key_project/util/testcategories/package-info.java index a23e3782c42..f002a231713 100644 --- a/key.util/src/main/java/org/key_project/util/testcategories/package-info.java +++ b/key.util/src/main/java/org/key_project/util/testcategories/package-info.java @@ -7,4 +7,7 @@ * @date 2019-04-18 * @see "https://dzone.com/articles/closer-look-junit-categories" */ +@NullMarked package org.key_project.util.testcategories; + +import org.jspecify.annotations.NullMarked; \ No newline at end of file From b4d6ddaf9a32723337724ddab73d3c81aa4c4764 Mon Sep 17 00:00:00 2001 From: Florian Lanzinger Date: Wed, 25 Oct 2023 11:39:38 +0200 Subject: [PATCH 21/37] Fix type error in KeYCollections.concat --- build.gradle | 1 + .../org/key_project/util/collection/KeYCollections.java | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/build.gradle b/build.gradle index ccd25bd3fe4..bd1b31475b9 100644 --- a/build.gradle +++ b/build.gradle @@ -89,6 +89,7 @@ subprojects { compileOnly 'org.jspecify:jspecify:0.3.0' compileOnly 'io.github.eisop:checker-qual:3.34.0-eisop1' + compileOnly 'io.github.eisop:checker-util:3.34.0-eisop1' testCompileOnly 'io.github.eisop:checker-qual:3.34.0-eisop1' checkerFramework 'io.github.eisop:checker:3.34.0-eisop1' diff --git a/key.util/src/main/java/org/key_project/util/collection/KeYCollections.java b/key.util/src/main/java/org/key_project/util/collection/KeYCollections.java index 7edc8398df2..d30bdabb0de 100644 --- a/key.util/src/main/java/org/key_project/util/collection/KeYCollections.java +++ b/key.util/src/main/java/org/key_project/util/collection/KeYCollections.java @@ -1,5 +1,6 @@ package org.key_project.util.collection; +import org.checkerframework.checker.nullness.util.NullnessUtil; import org.jspecify.annotations.Nullable; import java.util.Arrays; @@ -24,10 +25,11 @@ public class KeYCollections { * Concatenates two arrays. The second array may have an entry type that is a subtype of the * first one. */ - public static S[] concat(S[] s1, T[] s2) { - S[] res = Arrays.copyOf(s1, s1.length + s2.length); + public static S[] concat(S[] s1, T[] s2) { + @Nullable S[] res = Arrays.copyOf(s1, s1.length + s2.length); System.arraycopy(s2, 0, res, s1.length, s2.length); - return res; + // After arraycopy, all elements of res are NonNull. + return NullnessUtil.castNonNullDeep(res); } // ======================================================= From ba9dad1fdd3e2b8d79b8e3b1ba0712d7a3cc998a Mon Sep 17 00:00:00 2001 From: Alexander Weigl Date: Fri, 3 Nov 2023 18:41:33 +0100 Subject: [PATCH 22/37] fix compile error --- .../java/org/key_project/util/collection/ImmutableSet.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/key.util/src/main/java/org/key_project/util/collection/ImmutableSet.java b/key.util/src/main/java/org/key_project/util/collection/ImmutableSet.java index 0a79c00f4b6..9cf5f187cd9 100644 --- a/key.util/src/main/java/org/key_project/util/collection/ImmutableSet.java +++ b/key.util/src/main/java/org/key_project/util/collection/ImmutableSet.java @@ -11,7 +11,6 @@ import org.jspecify.annotations.NullMarked; import org.jspecify.annotations.Nullable; -import org.jspecify.annotations.NonNull; /** * interface implemented by non-destructive Sets. CONVENTION: Each SetOf implementation has to @@ -47,10 +46,6 @@ public interface ImmutableSet return DefaultImmutableSet.nil(); } - static ImmutableSet fromCollection(Collection seq) { - return fromSet(new HashSet<>(seq)); - } - /** * @return a {@code Set} containing the same elements as this {@code ImmutableSet} */ From 9e4f5016efcf4eb06de0acefcd47a4bdf0e898dc Mon Sep 17 00:00:00 2001 From: Alexander Weigl Date: Fri, 3 Nov 2023 18:41:39 +0100 Subject: [PATCH 23/37] spotless --- .../rule/ModalitySideProofRule.java | 2 -- .../de/uka/ilkd/key/core/KeYMediator.java | 2 -- .../main/java/de/uka/ilkd/key/core/Log.java | 2 +- .../key/gui/KeYFileChooserBookmarkPanel.java | 1 - .../ilkd/key/gui/KeyboardTacletExtension.java | 4 +-- .../java/de/uka/ilkd/key/gui/MainWindow.java | 2 +- .../ilkd/key/gui/PositionedIssueString.java | 3 ++- .../ilkd/key/gui/ProofManagementDialog.java | 4 +-- .../java/de/uka/ilkd/key/gui/SearchBar.java | 3 ++- .../key/gui/actions/EditSourceFileAction.java | 2 +- .../gui/actions/LemmaGenerationAction.java | 2 +- .../key/gui/actions/RunAllProofsAction.java | 4 +-- .../ilkd/key/gui/docking/DockingHelper.java | 2 +- .../ilkd/key/gui/docking/DockingLayout.java | 2 +- .../gui/extension/api/KeYGuiExtension.java | 3 ++- .../ilkd/key/gui/extension/api/TabPanel.java | 4 +-- .../key/gui/extension/impl/TestExtension.java | 2 +- .../gui/lemmatagenerator/LemmataHandler.java | 2 +- .../gui/nodeviews/SequentViewSearchBar.java | 3 ++- .../javac/JavaCompilerCheckFacade.java | 2 +- .../gui/prooftree/GUIAbstractTreeNode.java | 3 ++- .../ilkd/key/gui/prooftree/GUIBranchNode.java | 3 ++- .../prooftree/GUIOneStepChildTreeNode.java | 1 - .../key/gui/prooftree/GUIProofTreeModel.java | 2 +- .../key/gui/prooftree/GUIProofTreeNode.java | 3 ++- .../prooftree/ProofTreeExpansionState.java | 3 ++- .../key/gui/prooftree/ProofTreeSearchBar.java | 3 ++- .../ilkd/key/gui/prooftree/ProofTreeView.java | 2 +- .../de/uka/ilkd/key/gui/prooftree/Style.java | 3 ++- .../ilkd/key/gui/settings/SettingsPanel.java | 2 +- .../key/gui/settings/SimpleSettingsPanel.java | 2 +- .../gui/settings/TacletOptionsSettings.java | 1 - .../java/org/key_project/util/ExtList.java | 8 +++--- .../java/org/key_project/util/LRUCache.java | 4 +-- .../java/org/key_project/util/RandomName.java | 1 - .../java/org/key_project/util/Strings.java | 10 +++---- .../bitops/ImmutableFixedLengthBitSet.java | 5 ++-- .../util/collection/DefaultImmutableSet.java | 4 +-- .../util/collection/ImmutableList.java | 11 ++++---- .../util/collection/ImmutableSLList.java | 26 +++++++++---------- .../util/collection/Immutables.java | 1 - .../util/collection/KeYCollections.java | 9 ++++--- .../util/collection/package-info.java | 2 +- .../util/helper/FindResources.java | 24 +++++++++-------- .../key_project/util/helper/package-info.java | 5 ++-- .../org/key_project/util/java/ArrayUtil.java | 1 - .../key_project/util/java/CollectionUtil.java | 7 ++--- .../org/key_project/util/java/IOUtil.java | 24 ++++++++++------- .../key_project/util/java/IntegerUtil.java | 1 - .../org/key_project/util/java/NumberUtil.java | 1 - .../org/key_project/util/java/StringUtil.java | 1 - .../org/key_project/util/java/WrapUtils.java | 1 - .../org/key_project/util/java/XMLUtil.java | 15 ++++++----- .../key_project/util/java/package-info.java | 5 ++-- .../java/thread/IRunnableWithException.java | 3 ++- .../util/java/thread/IRunnableWithResult.java | 6 +++-- .../util/java/thread/package-info.java | 5 ++-- .../org/key_project/util/package-info.java | 5 ++-- .../util/reflection/ClassLoaderUtil.java | 4 +-- .../util/reflection/IClassLoader.java | 4 +-- .../JavaApplicationClassLoader.java | 4 +-- .../util/testcategories/package-info.java | 2 +- .../org/key_project/util/model/ClassA.java | 2 +- .../exploration/ExplorationExtension.java | 3 ++- .../exploration/ExplorationModeModel.java | 1 - .../exploration/ExplorationNodeData.java | 5 ++-- .../exploration/ProofExplorationService.java | 5 ++-- .../actions/AddFormulaToAntecedentAction.java | 3 ++- .../actions/AddFormulaToSuccedentAction.java | 3 ++- .../exploration/ui/ExplorationStepsList.java | 4 +-- .../key_project/slicing/SlicingExtension.java | 3 ++- .../slicing/ui/SlicingLeftPanel.java | 2 +- .../key/gui/testgen/TestgenExtension.java | 3 ++- 73 files changed, 162 insertions(+), 150 deletions(-) diff --git a/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/rule/ModalitySideProofRule.java b/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/rule/ModalitySideProofRule.java index e27bf393c7f..fb3201b73c9 100644 --- a/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/rule/ModalitySideProofRule.java +++ b/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/rule/ModalitySideProofRule.java @@ -7,8 +7,6 @@ import java.util.List; import java.util.Set; -import org.jspecify.annotations.NonNull; - import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.logic.Name; import de.uka.ilkd.key.logic.PosInOccurrence; diff --git a/key.ui/src/main/java/de/uka/ilkd/key/core/KeYMediator.java b/key.ui/src/main/java/de/uka/ilkd/key/core/KeYMediator.java index a9a9543effa..9eeda034ce3 100644 --- a/key.ui/src/main/java/de/uka/ilkd/key/core/KeYMediator.java +++ b/key.ui/src/main/java/de/uka/ilkd/key/core/KeYMediator.java @@ -7,8 +7,6 @@ import java.util.Collection; import java.util.EventObject; import java.util.function.Consumer; -import org.jspecify.annotations.NonNull; -import org.jspecify.annotations.Nullable; import javax.swing.*; import javax.swing.event.EventListenerList; diff --git a/key.ui/src/main/java/de/uka/ilkd/key/core/Log.java b/key.ui/src/main/java/de/uka/ilkd/key/core/Log.java index b245c82564a..4d8d25cd644 100644 --- a/key.ui/src/main/java/de/uka/ilkd/key/core/Log.java +++ b/key.ui/src/main/java/de/uka/ilkd/key/core/Log.java @@ -11,7 +11,6 @@ import java.time.Duration; import java.time.Instant; import java.time.temporal.ChronoUnit; -import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.settings.PathConfig; import de.uka.ilkd.key.ui.Verbosity; @@ -20,6 +19,7 @@ import ch.qos.logback.classic.spi.ILoggingEvent; import ch.qos.logback.core.Appender; import ch.qos.logback.core.FileAppender; +import org.jspecify.annotations.Nullable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/key.ui/src/main/java/de/uka/ilkd/key/gui/KeYFileChooserBookmarkPanel.java b/key.ui/src/main/java/de/uka/ilkd/key/gui/KeYFileChooserBookmarkPanel.java index 9cb2e949b15..caf9062785f 100644 --- a/key.ui/src/main/java/de/uka/ilkd/key/gui/KeYFileChooserBookmarkPanel.java +++ b/key.ui/src/main/java/de/uka/ilkd/key/gui/KeYFileChooserBookmarkPanel.java @@ -9,7 +9,6 @@ import java.util.ArrayList; import java.util.Enumeration; import java.util.List; -import org.jspecify.annotations.NonNull; import javax.swing.*; import javax.swing.filechooser.FileFilter; diff --git a/key.ui/src/main/java/de/uka/ilkd/key/gui/KeyboardTacletExtension.java b/key.ui/src/main/java/de/uka/ilkd/key/gui/KeyboardTacletExtension.java index f509fdb8fb2..1e5dc67fef0 100644 --- a/key.ui/src/main/java/de/uka/ilkd/key/gui/KeyboardTacletExtension.java +++ b/key.ui/src/main/java/de/uka/ilkd/key/gui/KeyboardTacletExtension.java @@ -10,8 +10,6 @@ import java.util.*; import java.util.List; import java.util.stream.Collectors; -import org.jspecify.annotations.NonNull; -import org.jspecify.annotations.Nullable; import javax.swing.*; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; @@ -43,6 +41,8 @@ import bibliothek.gui.dock.common.action.CDropDownButton; import net.miginfocom.layout.CC; import net.miginfocom.swing.MigLayout; +import org.jspecify.annotations.NonNull; +import org.jspecify.annotations.Nullable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/key.ui/src/main/java/de/uka/ilkd/key/gui/MainWindow.java b/key.ui/src/main/java/de/uka/ilkd/key/gui/MainWindow.java index e26f0ab3793..0dbd4fc5331 100644 --- a/key.ui/src/main/java/de/uka/ilkd/key/gui/MainWindow.java +++ b/key.ui/src/main/java/de/uka/ilkd/key/gui/MainWindow.java @@ -19,7 +19,6 @@ import java.util.prefs.BackingStoreException; import java.util.prefs.Preferences; import java.util.stream.Stream; -import org.jspecify.annotations.NonNull; import javax.swing.*; import javax.swing.event.ChangeListener; import javax.swing.event.MenuEvent; @@ -73,6 +72,7 @@ import bibliothek.gui.dock.common.SingleCDockable; import bibliothek.gui.dock.common.intern.CDockable; import bibliothek.gui.dock.station.stack.tab.layouting.TabPlacement; +import org.jspecify.annotations.NonNull; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/key.ui/src/main/java/de/uka/ilkd/key/gui/PositionedIssueString.java b/key.ui/src/main/java/de/uka/ilkd/key/gui/PositionedIssueString.java index 62656b5d2dd..25d072d183b 100644 --- a/key.ui/src/main/java/de/uka/ilkd/key/gui/PositionedIssueString.java +++ b/key.ui/src/main/java/de/uka/ilkd/key/gui/PositionedIssueString.java @@ -4,12 +4,13 @@ package de.uka.ilkd.key.gui; import java.util.Objects; -import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.java.Position; import de.uka.ilkd.key.parser.Location; import de.uka.ilkd.key.speclang.PositionedString; +import org.jspecify.annotations.NonNull; + /** * Small data class that in addition to the information already contained by PositionedString * (text, filename, position) contains a String for additional information which can be used to diff --git a/key.ui/src/main/java/de/uka/ilkd/key/gui/ProofManagementDialog.java b/key.ui/src/main/java/de/uka/ilkd/key/gui/ProofManagementDialog.java index 7f40ab2c782..620e78b1b34 100644 --- a/key.ui/src/main/java/de/uka/ilkd/key/gui/ProofManagementDialog.java +++ b/key.ui/src/main/java/de/uka/ilkd/key/gui/ProofManagementDialog.java @@ -14,8 +14,6 @@ import java.util.Optional; import java.util.Set; import java.util.stream.Stream; -import org.jspecify.annotations.NonNull; -import org.jspecify.annotations.Nullable; import javax.swing.*; import javax.swing.border.TitledBorder; @@ -46,6 +44,8 @@ import org.key_project.util.collection.DefaultImmutableSet; import org.key_project.util.collection.ImmutableSet; +import org.jspecify.annotations.NonNull; +import org.jspecify.annotations.Nullable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/key.ui/src/main/java/de/uka/ilkd/key/gui/SearchBar.java b/key.ui/src/main/java/de/uka/ilkd/key/gui/SearchBar.java index 2c265441e84..eb23135b3b6 100644 --- a/key.ui/src/main/java/de/uka/ilkd/key/gui/SearchBar.java +++ b/key.ui/src/main/java/de/uka/ilkd/key/gui/SearchBar.java @@ -5,7 +5,6 @@ import java.awt.*; import java.awt.event.KeyEvent; -import org.jspecify.annotations.NonNull; import javax.swing.*; import javax.swing.border.Border; import javax.swing.border.CompoundBorder; @@ -17,6 +16,8 @@ import de.uka.ilkd.key.gui.colors.ColorSettings; import de.uka.ilkd.key.gui.fonticons.IconFactory; +import org.jspecify.annotations.NonNull; + /* * Abstract parent class of SequentSearchBar and ProofTreeSearchPanel. Might be used for additional * search bars. diff --git a/key.ui/src/main/java/de/uka/ilkd/key/gui/actions/EditSourceFileAction.java b/key.ui/src/main/java/de/uka/ilkd/key/gui/actions/EditSourceFileAction.java index a88e5cf55f6..52e58dcbec8 100644 --- a/key.ui/src/main/java/de/uka/ilkd/key/gui/actions/EditSourceFileAction.java +++ b/key.ui/src/main/java/de/uka/ilkd/key/gui/actions/EditSourceFileAction.java @@ -16,7 +16,6 @@ import java.util.Optional; import java.util.Timer; import java.util.TimerTask; -import org.jspecify.annotations.Nullable; import javax.swing.*; import javax.swing.border.TitledBorder; import javax.swing.text.BadLocationException; @@ -34,6 +33,7 @@ import org.key_project.util.java.IOUtil; +import org.jspecify.annotations.Nullable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/key.ui/src/main/java/de/uka/ilkd/key/gui/actions/LemmaGenerationAction.java b/key.ui/src/main/java/de/uka/ilkd/key/gui/actions/LemmaGenerationAction.java index 499ab880ea6..eb7c8949547 100644 --- a/key.ui/src/main/java/de/uka/ilkd/key/gui/actions/LemmaGenerationAction.java +++ b/key.ui/src/main/java/de/uka/ilkd/key/gui/actions/LemmaGenerationAction.java @@ -6,7 +6,6 @@ import java.awt.event.ActionEvent; import java.io.File; import java.util.List; -import org.jspecify.annotations.Nullable; import javax.swing.*; import de.uka.ilkd.key.gui.IssueDialog; @@ -28,6 +27,7 @@ import org.key_project.util.collection.ImmutableList; import org.key_project.util.collection.ImmutableSet; +import org.jspecify.annotations.Nullable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/key.ui/src/main/java/de/uka/ilkd/key/gui/actions/RunAllProofsAction.java b/key.ui/src/main/java/de/uka/ilkd/key/gui/actions/RunAllProofsAction.java index 75d51026e8b..ceaba6d1bb1 100644 --- a/key.ui/src/main/java/de/uka/ilkd/key/gui/actions/RunAllProofsAction.java +++ b/key.ui/src/main/java/de/uka/ilkd/key/gui/actions/RunAllProofsAction.java @@ -10,8 +10,6 @@ import java.util.Collections; import java.util.List; import java.util.stream.Collectors; -import org.jspecify.annotations.NonNull; -import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.core.KeYMediator; import de.uka.ilkd.key.core.Main; @@ -21,6 +19,8 @@ import de.uka.ilkd.key.proof.io.ProblemLoader; import de.uka.ilkd.key.ui.MediatorProofControl; +import org.jspecify.annotations.NonNull; +import org.jspecify.annotations.Nullable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/key.ui/src/main/java/de/uka/ilkd/key/gui/docking/DockingHelper.java b/key.ui/src/main/java/de/uka/ilkd/key/gui/docking/DockingHelper.java index 317a90aeba0..5c76e148649 100644 --- a/key.ui/src/main/java/de/uka/ilkd/key/gui/docking/DockingHelper.java +++ b/key.ui/src/main/java/de/uka/ilkd/key/gui/docking/DockingHelper.java @@ -6,7 +6,6 @@ import java.util.LinkedList; import java.util.List; import java.util.stream.Stream; -import org.jspecify.annotations.NonNull; import javax.swing.Action; import javax.swing.Icon; import javax.swing.JComponent; @@ -33,6 +32,7 @@ import bibliothek.gui.dock.common.intern.action.CDecorateableAction; import bibliothek.gui.dock.control.focus.DefaultFocusRequest; import bibliothek.gui.dock.control.focus.FocusRequest; +import org.jspecify.annotations.NonNull; public class DockingHelper { public final static List LEFT_TOP_PANEL = new LinkedList<>(); diff --git a/key.ui/src/main/java/de/uka/ilkd/key/gui/docking/DockingLayout.java b/key.ui/src/main/java/de/uka/ilkd/key/gui/docking/DockingLayout.java index d6b9d955324..68fa871169e 100644 --- a/key.ui/src/main/java/de/uka/ilkd/key/gui/docking/DockingLayout.java +++ b/key.ui/src/main/java/de/uka/ilkd/key/gui/docking/DockingLayout.java @@ -11,7 +11,6 @@ import java.io.IOException; import java.util.*; import java.util.List; -import org.jspecify.annotations.NonNull; import javax.swing.*; import de.uka.ilkd.key.core.KeYMediator; @@ -29,6 +28,7 @@ import bibliothek.gui.dock.common.CControl; import bibliothek.gui.dock.util.IconManager; import bibliothek.gui.dock.util.Priority; +import org.jspecify.annotations.NonNull; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/key.ui/src/main/java/de/uka/ilkd/key/gui/extension/api/KeYGuiExtension.java b/key.ui/src/main/java/de/uka/ilkd/key/gui/extension/api/KeYGuiExtension.java index a5a00f5d5b3..ef94d9dc7df 100644 --- a/key.ui/src/main/java/de/uka/ilkd/key/gui/extension/api/KeYGuiExtension.java +++ b/key.ui/src/main/java/de/uka/ilkd/key/gui/extension/api/KeYGuiExtension.java @@ -7,7 +7,6 @@ import java.lang.annotation.RetentionPolicy; import java.util.Collection; import java.util.List; -import org.jspecify.annotations.NonNull; import javax.swing.Action; import javax.swing.JComponent; import javax.swing.JMenu; @@ -25,6 +24,8 @@ import de.uka.ilkd.key.gui.sourceview.SourceView; import de.uka.ilkd.key.pp.PosInSequent; +import org.jspecify.annotations.NonNull; + /** * A marker interface for extension of the KeY GUI. Every extension should implement this interface * and should be registered in a service loader file META-INF/services/KeYGuiExtension. diff --git a/key.ui/src/main/java/de/uka/ilkd/key/gui/extension/api/TabPanel.java b/key.ui/src/main/java/de/uka/ilkd/key/gui/extension/api/TabPanel.java index f084be48813..6c7dc4b05ba 100644 --- a/key.ui/src/main/java/de/uka/ilkd/key/gui/extension/api/TabPanel.java +++ b/key.ui/src/main/java/de/uka/ilkd/key/gui/extension/api/TabPanel.java @@ -5,12 +5,12 @@ import java.util.Collection; import java.util.Collections; -import org.jspecify.annotations.NonNull; -import org.jspecify.annotations.Nullable; import javax.swing.*; import bibliothek.gui.dock.common.action.CAction; import bibliothek.gui.dock.common.intern.DefaultCDockable; +import org.jspecify.annotations.NonNull; +import org.jspecify.annotations.Nullable; /** * @author Alexander Weigl diff --git a/key.ui/src/main/java/de/uka/ilkd/key/gui/extension/impl/TestExtension.java b/key.ui/src/main/java/de/uka/ilkd/key/gui/extension/impl/TestExtension.java index e9bf811b32f..f2a34130abf 100644 --- a/key.ui/src/main/java/de/uka/ilkd/key/gui/extension/impl/TestExtension.java +++ b/key.ui/src/main/java/de/uka/ilkd/key/gui/extension/impl/TestExtension.java @@ -9,7 +9,6 @@ import java.util.Collection; import java.util.Collections; import java.util.List; -import org.jspecify.annotations.NonNull; import javax.swing.*; import de.uka.ilkd.key.core.KeYMediator; @@ -28,6 +27,7 @@ import de.uka.ilkd.key.proof.Proof; import de.uka.ilkd.key.rule.Rule; +import org.jspecify.annotations.NonNull; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/key.ui/src/main/java/de/uka/ilkd/key/gui/lemmatagenerator/LemmataHandler.java b/key.ui/src/main/java/de/uka/ilkd/key/gui/lemmatagenerator/LemmataHandler.java index 06ce6569769..3b2f4191af6 100644 --- a/key.ui/src/main/java/de/uka/ilkd/key/gui/lemmatagenerator/LemmataHandler.java +++ b/key.ui/src/main/java/de/uka/ilkd/key/gui/lemmatagenerator/LemmataHandler.java @@ -8,7 +8,6 @@ import java.util.Collection; import java.util.LinkedList; import java.util.List; -import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.proof.Proof; @@ -30,6 +29,7 @@ import org.key_project.util.collection.DefaultImmutableSet; import org.key_project.util.collection.ImmutableSet; +import org.jspecify.annotations.Nullable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/key.ui/src/main/java/de/uka/ilkd/key/gui/nodeviews/SequentViewSearchBar.java b/key.ui/src/main/java/de/uka/ilkd/key/gui/nodeviews/SequentViewSearchBar.java index 7caa415da51..c1dde27e29f 100644 --- a/key.ui/src/main/java/de/uka/ilkd/key/gui/nodeviews/SequentViewSearchBar.java +++ b/key.ui/src/main/java/de/uka/ilkd/key/gui/nodeviews/SequentViewSearchBar.java @@ -11,7 +11,6 @@ import java.util.Objects; import java.util.regex.Matcher; import java.util.regex.Pattern; -import org.jspecify.annotations.NonNull; import javax.swing.*; import de.uka.ilkd.key.gui.SearchBar; @@ -20,6 +19,8 @@ import de.uka.ilkd.key.pp.*; import de.uka.ilkd.key.util.Pair; +import org.jspecify.annotations.NonNull; + /* * Search bar implementing search function for SequentView. */ diff --git a/key.ui/src/main/java/de/uka/ilkd/key/gui/plugins/javac/JavaCompilerCheckFacade.java b/key.ui/src/main/java/de/uka/ilkd/key/gui/plugins/javac/JavaCompilerCheckFacade.java index 8f24ef15033..4332575eb41 100644 --- a/key.ui/src/main/java/de/uka/ilkd/key/gui/plugins/javac/JavaCompilerCheckFacade.java +++ b/key.ui/src/main/java/de/uka/ilkd/key/gui/plugins/javac/JavaCompilerCheckFacade.java @@ -15,7 +15,6 @@ import java.util.*; import java.util.concurrent.CompletableFuture; import java.util.stream.Collectors; -import org.jspecify.annotations.NonNull; import javax.tools.*; import de.uka.ilkd.key.gui.PositionedIssueString; @@ -23,6 +22,7 @@ import de.uka.ilkd.key.parser.Location; import de.uka.ilkd.key.proof.init.ProblemInitializer; +import org.jspecify.annotations.NonNull; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/key.ui/src/main/java/de/uka/ilkd/key/gui/prooftree/GUIAbstractTreeNode.java b/key.ui/src/main/java/de/uka/ilkd/key/gui/prooftree/GUIAbstractTreeNode.java index 99ab87115c4..8beb87fcb2f 100644 --- a/key.ui/src/main/java/de/uka/ilkd/key/gui/prooftree/GUIAbstractTreeNode.java +++ b/key.ui/src/main/java/de/uka/ilkd/key/gui/prooftree/GUIAbstractTreeNode.java @@ -7,11 +7,12 @@ import java.lang.ref.WeakReference; import java.util.Enumeration; import java.util.LinkedList; -import org.jspecify.annotations.NonNull; import javax.swing.tree.TreeNode; import de.uka.ilkd.key.proof.Node; +import org.jspecify.annotations.NonNull; + public abstract class GUIAbstractTreeNode implements TreeNode { private final GUIProofTreeModel tree; diff --git a/key.ui/src/main/java/de/uka/ilkd/key/gui/prooftree/GUIBranchNode.java b/key.ui/src/main/java/de/uka/ilkd/key/gui/prooftree/GUIBranchNode.java index 623957fd5a8..bff237c9860 100644 --- a/key.ui/src/main/java/de/uka/ilkd/key/gui/prooftree/GUIBranchNode.java +++ b/key.ui/src/main/java/de/uka/ilkd/key/gui/prooftree/GUIBranchNode.java @@ -6,11 +6,12 @@ * this class implements a TreeModel that can be displayed using the JTree class framework */ -import org.jspecify.annotations.NonNull; import javax.swing.tree.TreeNode; import de.uka.ilkd.key.proof.Node; +import org.jspecify.annotations.NonNull; + class GUIBranchNode extends GUIAbstractTreeNode implements TreeNode { private final Object label; diff --git a/key.ui/src/main/java/de/uka/ilkd/key/gui/prooftree/GUIOneStepChildTreeNode.java b/key.ui/src/main/java/de/uka/ilkd/key/gui/prooftree/GUIOneStepChildTreeNode.java index a767bf0ea48..55c8cd0ab68 100644 --- a/key.ui/src/main/java/de/uka/ilkd/key/gui/prooftree/GUIOneStepChildTreeNode.java +++ b/key.ui/src/main/java/de/uka/ilkd/key/gui/prooftree/GUIOneStepChildTreeNode.java @@ -3,7 +3,6 @@ * SPDX-License-Identifier: GPL-2.0-only */ package de.uka.ilkd.key.gui.prooftree; -import org.jspecify.annotations.NonNull; import javax.swing.tree.TreeNode; import de.uka.ilkd.key.java.Services; diff --git a/key.ui/src/main/java/de/uka/ilkd/key/gui/prooftree/GUIProofTreeModel.java b/key.ui/src/main/java/de/uka/ilkd/key/gui/prooftree/GUIProofTreeModel.java index eac8c12a762..b132d5bd5ad 100644 --- a/key.ui/src/main/java/de/uka/ilkd/key/gui/prooftree/GUIProofTreeModel.java +++ b/key.ui/src/main/java/de/uka/ilkd/key/gui/prooftree/GUIProofTreeModel.java @@ -4,7 +4,6 @@ package de.uka.ilkd.key.gui.prooftree; import java.util.*; -import org.jspecify.annotations.NonNull; import javax.swing.event.EventListenerList; import javax.swing.event.TreeModelEvent; import javax.swing.event.TreeModelListener; @@ -18,6 +17,7 @@ import org.key_project.util.collection.ImmutableList; +import org.jspecify.annotations.NonNull; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/key.ui/src/main/java/de/uka/ilkd/key/gui/prooftree/GUIProofTreeNode.java b/key.ui/src/main/java/de/uka/ilkd/key/gui/prooftree/GUIProofTreeNode.java index fa511a03488..82d36765ae8 100644 --- a/key.ui/src/main/java/de/uka/ilkd/key/gui/prooftree/GUIProofTreeNode.java +++ b/key.ui/src/main/java/de/uka/ilkd/key/gui/prooftree/GUIProofTreeNode.java @@ -6,13 +6,14 @@ * this class implements a TreeModel that can be displayed using the JTree class framework */ -import org.jspecify.annotations.NonNull; import javax.swing.tree.TreeNode; import de.uka.ilkd.key.proof.Node; import de.uka.ilkd.key.rule.OneStepSimplifier.Protocol; import de.uka.ilkd.key.rule.OneStepSimplifierRuleApp; +import org.jspecify.annotations.NonNull; + class GUIProofTreeNode extends GUIAbstractTreeNode { private GUIAbstractTreeNode[] children; diff --git a/key.ui/src/main/java/de/uka/ilkd/key/gui/prooftree/ProofTreeExpansionState.java b/key.ui/src/main/java/de/uka/ilkd/key/gui/prooftree/ProofTreeExpansionState.java index 3d935384eac..8402266b162 100644 --- a/key.ui/src/main/java/de/uka/ilkd/key/gui/prooftree/ProofTreeExpansionState.java +++ b/key.ui/src/main/java/de/uka/ilkd/key/gui/prooftree/ProofTreeExpansionState.java @@ -11,12 +11,13 @@ import java.util.*; import java.util.function.Predicate; -import org.jspecify.annotations.NonNull; import javax.swing.JTree; import javax.swing.event.*; import javax.swing.tree.TreeModel; import javax.swing.tree.TreePath; +import org.jspecify.annotations.NonNull; + /** * Cache/Access JTree's expansion state. The interface of JTree to access the expanded paths is * rather incomplete, since expanded paths under collapsed ancestors cannot be accessed at all diff --git a/key.ui/src/main/java/de/uka/ilkd/key/gui/prooftree/ProofTreeSearchBar.java b/key.ui/src/main/java/de/uka/ilkd/key/gui/prooftree/ProofTreeSearchBar.java index c7da8ee7b52..204e8a91cd9 100644 --- a/key.ui/src/main/java/de/uka/ilkd/key/gui/prooftree/ProofTreeSearchBar.java +++ b/key.ui/src/main/java/de/uka/ilkd/key/gui/prooftree/ProofTreeSearchBar.java @@ -5,7 +5,6 @@ import java.util.ArrayList; import java.util.List; -import org.jspecify.annotations.NonNull; import javax.swing.event.TreeModelEvent; import javax.swing.event.TreeModelListener; import javax.swing.text.Position; @@ -14,6 +13,8 @@ import de.uka.ilkd.key.gui.SearchBar; import de.uka.ilkd.key.util.Pair; +import org.jspecify.annotations.NonNull; + class ProofTreeSearchBar extends SearchBar implements TreeModelListener { private static final long serialVersionUID = 683318838568020629L; diff --git a/key.ui/src/main/java/de/uka/ilkd/key/gui/prooftree/ProofTreeView.java b/key.ui/src/main/java/de/uka/ilkd/key/gui/prooftree/ProofTreeView.java index 55964d34b9d..1fbb39f452a 100644 --- a/key.ui/src/main/java/de/uka/ilkd/key/gui/prooftree/ProofTreeView.java +++ b/key.ui/src/main/java/de/uka/ilkd/key/gui/prooftree/ProofTreeView.java @@ -7,7 +7,6 @@ import java.awt.event.*; import java.util.*; import java.util.List; -import org.jspecify.annotations.NonNull; import javax.swing.*; import javax.swing.event.TreeSelectionEvent; import javax.swing.event.TreeSelectionListener; @@ -44,6 +43,7 @@ import org.key_project.util.collection.ImmutableSLList; import bibliothek.gui.dock.common.action.CAction; +import org.jspecify.annotations.NonNull; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/key.ui/src/main/java/de/uka/ilkd/key/gui/prooftree/Style.java b/key.ui/src/main/java/de/uka/ilkd/key/gui/prooftree/Style.java index de0c1f28f43..0e35c2c6990 100644 --- a/key.ui/src/main/java/de/uka/ilkd/key/gui/prooftree/Style.java +++ b/key.ui/src/main/java/de/uka/ilkd/key/gui/prooftree/Style.java @@ -7,11 +7,12 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; -import org.jspecify.annotations.NonNull; import javax.swing.Icon; import de.uka.ilkd.key.pp.LogicPrinter; +import org.jspecify.annotations.NonNull; + /** * @author Alexander Weigl * @version 1 (20.05.19) diff --git a/key.ui/src/main/java/de/uka/ilkd/key/gui/settings/SettingsPanel.java b/key.ui/src/main/java/de/uka/ilkd/key/gui/settings/SettingsPanel.java index 8453f6bb7af..5e67068106d 100644 --- a/key.ui/src/main/java/de/uka/ilkd/key/gui/settings/SettingsPanel.java +++ b/key.ui/src/main/java/de/uka/ilkd/key/gui/settings/SettingsPanel.java @@ -8,7 +8,6 @@ import java.io.File; import java.util.Arrays; import java.util.List; -import org.jspecify.annotations.Nullable; import javax.swing.*; import de.uka.ilkd.key.gui.KeYFileChooser; @@ -19,6 +18,7 @@ import net.miginfocom.layout.CC; import net.miginfocom.layout.LC; import net.miginfocom.swing.MigLayout; +import org.jspecify.annotations.Nullable; /** * Extension of {@link SimpleSettingsPanel} which uses {@link MigLayout} to create a nice diff --git a/key.ui/src/main/java/de/uka/ilkd/key/gui/settings/SimpleSettingsPanel.java b/key.ui/src/main/java/de/uka/ilkd/key/gui/settings/SimpleSettingsPanel.java index dc8001c5a43..a951b15d42a 100644 --- a/key.ui/src/main/java/de/uka/ilkd/key/gui/settings/SimpleSettingsPanel.java +++ b/key.ui/src/main/java/de/uka/ilkd/key/gui/settings/SimpleSettingsPanel.java @@ -6,7 +6,6 @@ import java.awt.*; import java.text.Format; -import org.jspecify.annotations.Nullable; import javax.swing.*; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; @@ -20,6 +19,7 @@ import org.key_project.util.java.StringUtil; +import org.jspecify.annotations.Nullable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/key.ui/src/main/java/de/uka/ilkd/key/gui/settings/TacletOptionsSettings.java b/key.ui/src/main/java/de/uka/ilkd/key/gui/settings/TacletOptionsSettings.java index 944c8b712ab..4429744d19b 100644 --- a/key.ui/src/main/java/de/uka/ilkd/key/gui/settings/TacletOptionsSettings.java +++ b/key.ui/src/main/java/de/uka/ilkd/key/gui/settings/TacletOptionsSettings.java @@ -14,7 +14,6 @@ import java.util.*; import java.util.List; import java.util.stream.Collectors; -import org.jspecify.annotations.NonNull; import javax.swing.*; import de.uka.ilkd.key.gui.MainWindow; diff --git a/key.util/src/main/java/org/key_project/util/ExtList.java b/key.util/src/main/java/org/key_project/util/ExtList.java index 3c8ba608b67..9cfb09fdaef 100644 --- a/key.util/src/main/java/org/key_project/util/ExtList.java +++ b/key.util/src/main/java/org/key_project/util/ExtList.java @@ -4,14 +4,12 @@ package org.key_project.util; -import org.jspecify.annotations.NonNull; -import org.jspecify.annotations.NullMarked; -import org.jspecify.annotations.Nullable; - import java.util.Arrays; import java.util.Iterator; import java.util.LinkedList; -import java.util.List; + +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; /** * Extends java.util.LinkedList in order to collect elements according to their type. diff --git a/key.util/src/main/java/org/key_project/util/LRUCache.java b/key.util/src/main/java/org/key_project/util/LRUCache.java index 0a5aa091a81..39d8440e900 100644 --- a/key.util/src/main/java/org/key_project/util/LRUCache.java +++ b/key.util/src/main/java/org/key_project/util/LRUCache.java @@ -3,11 +3,11 @@ * SPDX-License-Identifier: GPL-2.0-only */ package org.key_project.util; -import org.jspecify.annotations.NullMarked; - import java.util.LinkedHashMap; import java.util.Map; +import org.jspecify.annotations.NullMarked; + /** * Simple realisation of an LRU cache. */ diff --git a/key.util/src/main/java/org/key_project/util/RandomName.java b/key.util/src/main/java/org/key_project/util/RandomName.java index a510fa301ce..ff58440b2b1 100644 --- a/key.util/src/main/java/org/key_project/util/RandomName.java +++ b/key.util/src/main/java/org/key_project/util/RandomName.java @@ -3,7 +3,6 @@ * SPDX-License-Identifier: GPL-2.0-only */ package org.key_project.util; -import org.jspecify.annotations.NullMarked; import java.util.Random; diff --git a/key.util/src/main/java/org/key_project/util/Strings.java b/key.util/src/main/java/org/key_project/util/Strings.java index 338c49d109f..c3239441ba2 100644 --- a/key.util/src/main/java/org/key_project/util/Strings.java +++ b/key.util/src/main/java/org/key_project/util/Strings.java @@ -3,16 +3,14 @@ * SPDX-License-Identifier: GPL-2.0-only */ package org.key_project.util; -import org.key_project.util.java.StringUtil; - -import org.jspecify.annotations.NullMarked; - import java.util.function.Function; -import java.util.regex.Matcher; -import java.util.regex.Pattern; import java.util.stream.Collectors; import java.util.stream.StreamSupport; +import org.key_project.util.java.StringUtil; + +import org.jspecify.annotations.NullMarked; + /** * Helper functions for {@link String}s * diff --git a/key.util/src/main/java/org/key_project/util/bitops/ImmutableFixedLengthBitSet.java b/key.util/src/main/java/org/key_project/util/bitops/ImmutableFixedLengthBitSet.java index c3a038520f3..e501d56e68c 100644 --- a/key.util/src/main/java/org/key_project/util/bitops/ImmutableFixedLengthBitSet.java +++ b/key.util/src/main/java/org/key_project/util/bitops/ImmutableFixedLengthBitSet.java @@ -3,12 +3,11 @@ * SPDX-License-Identifier: GPL-2.0-only */ package org.key_project.util.bitops; -import org.jspecify.annotations.NullMarked; -import org.jspecify.annotations.Nullable; - import java.util.ArrayList; import java.util.BitSet; +import org.jspecify.annotations.NullMarked; + /** * Represents a non-negative number with access to single bits; the length of the bit set is fixed. * Comparable to {@link BitSet} with fixed length. Objects of this class are immutable. diff --git a/key.util/src/main/java/org/key_project/util/collection/DefaultImmutableSet.java b/key.util/src/main/java/org/key_project/util/collection/DefaultImmutableSet.java index 7ff1e39dcb4..a4538d73600 100644 --- a/key.util/src/main/java/org/key_project/util/collection/DefaultImmutableSet.java +++ b/key.util/src/main/java/org/key_project/util/collection/DefaultImmutableSet.java @@ -10,11 +10,11 @@ import java.util.stream.Stream; import java.util.stream.StreamSupport; +import org.key_project.util.Strings; + import org.jspecify.annotations.NullMarked; import org.jspecify.annotations.Nullable; -import org.key_project.util.Strings; - /** * implementation of a persistent set using the SLListOf implementation with all its implications * (means e.g. O(n) for adding an element, searching for an element and so on). diff --git a/key.util/src/main/java/org/key_project/util/collection/ImmutableList.java b/key.util/src/main/java/org/key_project/util/collection/ImmutableList.java index a5862f59078..7c2eab4c14c 100644 --- a/key.util/src/main/java/org/key_project/util/collection/ImmutableList.java +++ b/key.util/src/main/java/org/key_project/util/collection/ImmutableList.java @@ -3,11 +3,6 @@ * SPDX-License-Identifier: GPL-2.0-only */ package org.key_project.util.collection; -import org.checkerframework.checker.nullness.qual.EnsuresNonNullIf; -import org.jspecify.annotations.NullMarked; -import org.jspecify.annotations.Nullable; -import org.jspecify.annotations.NonNull; - import java.util.*; import java.util.function.Function; import java.util.function.Predicate; @@ -15,11 +10,15 @@ import java.util.stream.Stream; import java.util.stream.StreamSupport; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; + /** * List interface to be implemented by non-destructive lists */ @NullMarked -public interface ImmutableList extends Iterable, java.io.Serializable { +public interface ImmutableList + extends Iterable, java.io.Serializable { /** * Returns a Collector that accumulates the input elements into a new ImmutableList. diff --git a/key.util/src/main/java/org/key_project/util/collection/ImmutableSLList.java b/key.util/src/main/java/org/key_project/util/collection/ImmutableSLList.java index bd75aa70e43..cb9d28b2c4a 100644 --- a/key.util/src/main/java/org/key_project/util/collection/ImmutableSLList.java +++ b/key.util/src/main/java/org/key_project/util/collection/ImmutableSLList.java @@ -3,13 +3,6 @@ * SPDX-License-Identifier: GPL-2.0-only */ package org.key_project.util.collection; -import org.checkerframework.checker.nullness.qual.EnsuresNonNullIf; -import org.jspecify.annotations.NonNull; -import org.jspecify.annotations.NullMarked; -import org.jspecify.annotations.Nullable; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import java.lang.reflect.Array; import java.util.*; import java.util.function.BiConsumer; @@ -17,11 +10,16 @@ import java.util.function.Function; import java.util.function.Predicate; import java.util.function.Supplier; -import java.util.logging.LogManager; import java.util.stream.Collector; import org.key_project.util.Strings; +import org.jspecify.annotations.NonNull; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + /** * Simple implementation of a non-destructive (unmodifiable) list. The list implementation allows * list sharing of sublists. @@ -78,7 +76,8 @@ public ImmutableList reverse() { S[] result; if (array.length < size()) { Class arrayClass = array.getClass(); - assert arrayClass.isArray() : "@AssumeAssertion(nullness): This has indeed a component type"; + assert arrayClass.isArray() + : "@AssumeAssertion(nullness): This has indeed a component type"; result = (S[]) Array.newInstance(arrayClass.getComponentType(), size()); } else { result = array; @@ -100,9 +99,9 @@ public ImmutableList reverse() { S[] result = (S[]) Array.newInstance(type, size()); ImmutableList rest = this; for (int i = 0, sz = size(); i < sz; i++) { - //@ assert !rest.isEmpty(); + // @ assert !rest.isEmpty(); T head = rest.head(); - result[i] = (S)type.cast(head); + result[i] = (S) type.cast(head); rest = rest.tail(); } return result; @@ -240,9 +239,10 @@ public ImmutableList prepend(ImmutableList list) { } else { final int sz = list.size(); if (sz == 1) { - //@ assert !list.isEmpty(); + // @ assert !list.isEmpty(); @SuppressWarnings("nullness") - @NonNull S head = list.head(); + @NonNull + S head = list.head(); return new Cons<>(head, this); } Cons result = this; diff --git a/key.util/src/main/java/org/key_project/util/collection/Immutables.java b/key.util/src/main/java/org/key_project/util/collection/Immutables.java index dcb7cc6fe22..893772ceec3 100644 --- a/key.util/src/main/java/org/key_project/util/collection/Immutables.java +++ b/key.util/src/main/java/org/key_project/util/collection/Immutables.java @@ -7,7 +7,6 @@ import java.util.function.Function; import java.util.function.Predicate; -import org.jspecify.annotations.NullMarked; import org.jspecify.annotations.Nullable; /** diff --git a/key.util/src/main/java/org/key_project/util/collection/KeYCollections.java b/key.util/src/main/java/org/key_project/util/collection/KeYCollections.java index c11968a44dd..e6193c17e99 100644 --- a/key.util/src/main/java/org/key_project/util/collection/KeYCollections.java +++ b/key.util/src/main/java/org/key_project/util/collection/KeYCollections.java @@ -3,9 +3,6 @@ * SPDX-License-Identifier: GPL-2.0-only */ package org.key_project.util.collection; -import org.checkerframework.checker.nullness.util.NullnessUtil; -import org.jspecify.annotations.Nullable; - import java.util.Arrays; import java.util.HashMap; import java.util.Map; @@ -13,6 +10,9 @@ import java.util.stream.Collectors; import java.util.stream.StreamSupport; +import org.checkerframework.checker.nullness.util.NullnessUtil; +import org.jspecify.annotations.Nullable; + /** * Utilities for Collections. * @@ -29,7 +29,8 @@ public class KeYCollections { * first one. */ public static S[] concat(S[] s1, T[] s2) { - @Nullable S[] res = Arrays.copyOf(s1, s1.length + s2.length); + @Nullable + S[] res = Arrays.copyOf(s1, s1.length + s2.length); System.arraycopy(s2, 0, res, s1.length, s2.length); // After arraycopy, all elements of res are NonNull. return NullnessUtil.castNonNullDeep(res); diff --git a/key.util/src/main/java/org/key_project/util/collection/package-info.java b/key.util/src/main/java/org/key_project/util/collection/package-info.java index e782219bb9e..06e5b31dba6 100644 --- a/key.util/src/main/java/org/key_project/util/collection/package-info.java +++ b/key.util/src/main/java/org/key_project/util/collection/package-info.java @@ -5,4 +5,4 @@ @NullMarked package org.key_project.util.collection; -import org.jspecify.annotations.NullMarked; \ No newline at end of file +import org.jspecify.annotations.NullMarked; diff --git a/key.util/src/main/java/org/key_project/util/helper/FindResources.java b/key.util/src/main/java/org/key_project/util/helper/FindResources.java index d5307a38c8a..64f13ac7efd 100644 --- a/key.util/src/main/java/org/key_project/util/helper/FindResources.java +++ b/key.util/src/main/java/org/key_project/util/helper/FindResources.java @@ -3,10 +3,6 @@ * SPDX-License-Identifier: GPL-2.0-only */ package org.key_project.util.helper; -import org.checkerframework.checker.units.qual.N; -import org.jspecify.annotations.NullMarked; -import org.jspecify.annotations.Nullable; - import java.io.File; import java.io.IOException; import java.net.URISyntaxException; @@ -14,9 +10,10 @@ import java.nio.file.*; import java.util.Arrays; import java.util.List; -import java.util.Objects; import java.util.stream.Collectors; +import org.jspecify.annotations.Nullable; + /** * @author Alexander Weigl * @version 1 (13.02.19) @@ -37,13 +34,15 @@ public final class FindResources { throws URISyntaxException, IOException { final var classLoader = clazz.getClassLoader(); - if (classLoader == null) return null; + if (classLoader == null) + return null; - @Nullable URL dirURL = classLoader.getResource(path); + @Nullable + URL dirURL = classLoader.getResource(path); if (dirURL != null && dirURL.getProtocol().equals("file")) { /* A file path: easy enough */ File[] files = new File(dirURL.toURI()).listFiles(); - if(files == null) + if (files == null) files = new File[0]; return Arrays.stream(files).map(File::toPath).collect(Collectors.toList()); } @@ -76,14 +75,16 @@ public final class FindResources { throw new UnsupportedOperationException("Cannot list files for URL \"" + dirURL + "\""); } - public static @Nullable List getResources(String path) throws URISyntaxException, IOException { + public static @Nullable List getResources(String path) + throws URISyntaxException, IOException { return getResources(path, FindResources.class); } public static @Nullable Path getResource(String path, Class clazz) throws URISyntaxException, IOException { final var classLoader = clazz.getClassLoader(); - if(classLoader == null) return null; + if (classLoader == null) + return null; URL dirURL = classLoader.getResource(path); if (dirURL != null && dirURL.getProtocol().equals("file")) { return new File(dirURL.toURI()).toPath(); @@ -114,7 +115,8 @@ public final class FindResources { throw new UnsupportedOperationException("Cannot list files for URL \"" + dirURL + "\""); } - public static @Nullable Path getResource(String path) throws URISyntaxException, IOException { + public static @Nullable Path getResource(String path) + throws URISyntaxException, IOException { return getResource(path, FindResources.class); } diff --git a/key.util/src/main/java/org/key_project/util/helper/package-info.java b/key.util/src/main/java/org/key_project/util/helper/package-info.java index c9e748024b4..3472f55554e 100644 --- a/key.util/src/main/java/org/key_project/util/helper/package-info.java +++ b/key.util/src/main/java/org/key_project/util/helper/package-info.java @@ -2,6 +2,7 @@ * @author Alexander Weigl * @version 1 (24.07.23) */ -@NullMarked package org.key_project.util.helper; +@NullMarked +package org.key_project.util.helper; -import org.jspecify.annotations.NullMarked; \ No newline at end of file +import org.jspecify.annotations.NullMarked; diff --git a/key.util/src/main/java/org/key_project/util/java/ArrayUtil.java b/key.util/src/main/java/org/key_project/util/java/ArrayUtil.java index d16a2768709..86c1d991572 100644 --- a/key.util/src/main/java/org/key_project/util/java/ArrayUtil.java +++ b/key.util/src/main/java/org/key_project/util/java/ArrayUtil.java @@ -8,7 +8,6 @@ import java.util.Objects; import java.util.function.Predicate; -import org.jspecify.annotations.NullMarked; import org.jspecify.annotations.Nullable; /** diff --git a/key.util/src/main/java/org/key_project/util/java/CollectionUtil.java b/key.util/src/main/java/org/key_project/util/java/CollectionUtil.java index e251a8507f4..2baff6d4356 100644 --- a/key.util/src/main/java/org/key_project/util/java/CollectionUtil.java +++ b/key.util/src/main/java/org/key_project/util/java/CollectionUtil.java @@ -3,11 +3,11 @@ * SPDX-License-Identifier: GPL-2.0-only */ package org.key_project.util.java; -import org.jspecify.annotations.Nullable; - import java.util.*; import java.util.function.Predicate; +import org.jspecify.annotations.Nullable; + /** * Provides static methods to work with {@link Collection}s. * @@ -220,7 +220,8 @@ public static List searchAll(Iterable iterable, Predicate filter) { * @param filter The filter to select an element. * @return The found element or {@code null} if no element was found. */ - public static @Nullable T searchAndRemoveWithException(Iterable iterable, + public static @Nullable T searchAndRemoveWithException( + Iterable iterable, IFilterWithException filter) throws E { T result = null; if (iterable != null && filter != null) { diff --git a/key.util/src/main/java/org/key_project/util/java/IOUtil.java b/key.util/src/main/java/org/key_project/util/java/IOUtil.java index 41feba09126..d7183a789e5 100644 --- a/key.util/src/main/java/org/key_project/util/java/IOUtil.java +++ b/key.util/src/main/java/org/key_project/util/java/IOUtil.java @@ -3,11 +3,6 @@ * SPDX-License-Identifier: GPL-2.0-only */ package org.key_project.util.java; -import org.checkerframework.checker.nullness.qual.PolyNull; -import org.jspecify.annotations.NonNull; -import org.jspecify.annotations.NullMarked; -import org.jspecify.annotations.Nullable; - import java.io.*; import java.net.*; import java.nio.charset.Charset; @@ -21,6 +16,10 @@ import java.util.zip.ZipException; import java.util.zip.ZipInputStream; +import org.checkerframework.checker.nullness.qual.PolyNull; +import org.jspecify.annotations.NonNull; +import org.jspecify.annotations.Nullable; + /** * Provides static methods to work with java IO. * @@ -219,7 +218,8 @@ public static void writeTo(OutputStream out, String content, Charset encoding) * @param encoding The encoding to use. * @throws IOException Occurred Exception. */ - public static void writeTo(@Nullable OutputStream out, @Nullable String content, @Nullable String encoding) + public static void writeTo(@Nullable OutputStream out, @Nullable String content, + @Nullable String encoding) throws IOException { if (out == null || content == null) { return; @@ -304,7 +304,8 @@ public static LineInformation[] computeLineInformation(File file) throws IOExcep * @return The computed start indices. * @throws IOException Occurred Exception. */ - public static LineInformation[] computeLineInformation(@Nullable InputStream in) throws IOException { + public static LineInformation[] computeLineInformation(@Nullable InputStream in) + throws IOException { if (in == null) { return new LineInformation[0]; } @@ -597,7 +598,8 @@ public interface IFileVisitor { * @return A new {@link InputStream} with with the replaced line breaks. * @throws IOException Occurred Exception. */ - public static @PolyNull InputStream unifyLineBreaks(@PolyNull InputStream in) throws IOException { + public static @PolyNull InputStream unifyLineBreaks(@PolyNull InputStream in) + throws IOException { if (in != null) { String text = IOUtil.readFrom(in); text = text.replace("\r\n", "\n"); @@ -780,7 +782,8 @@ public static boolean exists(File file) { */ public static File getCurrentDirectory() { File result = new File(".").getAbsoluteFile().getParentFile(); - assert result != null : "@AssumeAssertion(nullness): this always works, even in the toplevel directory ..."; + assert result != null + : "@AssumeAssertion(nullness): this always works, even in the toplevel directory ..."; return result; } @@ -849,7 +852,8 @@ public static void extractZip(InputStream in, Path targetDir) throws IOException // Since path is the result of resolving a zip entry name in the // target directory, it does have a parent. @SuppressWarnings("nullness") - @NonNull Path parent = path.getParent(); + @NonNull + Path parent = path.getParent(); Files.createDirectories(parent); Files.copy(zin, path); } diff --git a/key.util/src/main/java/org/key_project/util/java/IntegerUtil.java b/key.util/src/main/java/org/key_project/util/java/IntegerUtil.java index c008e7d1bf6..240bc59f135 100644 --- a/key.util/src/main/java/org/key_project/util/java/IntegerUtil.java +++ b/key.util/src/main/java/org/key_project/util/java/IntegerUtil.java @@ -3,7 +3,6 @@ * SPDX-License-Identifier: GPL-2.0-only */ package org.key_project.util.java; -import org.jspecify.annotations.NullMarked; public final class IntegerUtil { /** diff --git a/key.util/src/main/java/org/key_project/util/java/NumberUtil.java b/key.util/src/main/java/org/key_project/util/java/NumberUtil.java index a9b10f2c758..bbf2c637d99 100644 --- a/key.util/src/main/java/org/key_project/util/java/NumberUtil.java +++ b/key.util/src/main/java/org/key_project/util/java/NumberUtil.java @@ -3,7 +3,6 @@ * SPDX-License-Identifier: GPL-2.0-only */ package org.key_project.util.java; -import org.jspecify.annotations.NullMarked; /** * Provides utility methods to work with numbers. diff --git a/key.util/src/main/java/org/key_project/util/java/StringUtil.java b/key.util/src/main/java/org/key_project/util/java/StringUtil.java index 81f235bb25c..51d8fae2f6e 100644 --- a/key.util/src/main/java/org/key_project/util/java/StringUtil.java +++ b/key.util/src/main/java/org/key_project/util/java/StringUtil.java @@ -12,7 +12,6 @@ import org.checkerframework.checker.nullness.qual.PolyNull; import org.jspecify.annotations.NonNull; -import org.jspecify.annotations.NullMarked; import org.jspecify.annotations.Nullable; diff --git a/key.util/src/main/java/org/key_project/util/java/WrapUtils.java b/key.util/src/main/java/org/key_project/util/java/WrapUtils.java index 16b10c465bf..88302a6710d 100644 --- a/key.util/src/main/java/org/key_project/util/java/WrapUtils.java +++ b/key.util/src/main/java/org/key_project/util/java/WrapUtils.java @@ -3,7 +3,6 @@ * SPDX-License-Identifier: GPL-2.0-only */ package org.key_project.util.java; -import org.jspecify.annotations.NullMarked; /** * This class provides a simple routine that performs line wrapping of strings that may contain long diff --git a/key.util/src/main/java/org/key_project/util/java/XMLUtil.java b/key.util/src/main/java/org/key_project/util/java/XMLUtil.java index c9fe69038fb..f74ba5e8c32 100644 --- a/key.util/src/main/java/org/key_project/util/java/XMLUtil.java +++ b/key.util/src/main/java/org/key_project/util/java/XMLUtil.java @@ -3,13 +3,11 @@ * SPDX-License-Identifier: GPL-2.0-only */ package org.key_project.util.java; -import org.jspecify.annotations.NonNull; -import org.jspecify.annotations.NullMarked; -import org.jspecify.annotations.Nullable; - import java.util.Map; import java.util.Map.Entry; +import org.jspecify.annotations.Nullable; + /** * Provides static methods to work with XML. * @@ -39,7 +37,8 @@ private XMLUtil() { * @param replacer The {@link ITagReplacer} to use. * @return The new created text. */ - public static @Nullable String replaceTags(@Nullable String text, @Nullable ITagReplacer replacer) { + public static @Nullable String replaceTags(@Nullable String text, + @Nullable ITagReplacer replacer) { if (text != null && replacer != null) { StringBuilder sb = new StringBuilder(); char[] signs = text.toCharArray(); @@ -56,7 +55,8 @@ private XMLUtil() { sb.append(sign); } } else { - assert tagSB != null : "@AssumeAssertion(nullness): tagSB must have been intialised already"; + assert tagSB != null + : "@AssumeAssertion(nullness): tagSB must have been intialised already"; tagSB.append(sign); if (sign == '>' && !inAttribute) { inTag = false; @@ -88,7 +88,8 @@ public interface ITagReplacer { * @param tag The found tag. * @return The replacement to use or {@code null} to remove the tag. */ - @Nullable String replaceTag(String tag); + @Nullable + String replaceTag(String tag); } /** diff --git a/key.util/src/main/java/org/key_project/util/java/package-info.java b/key.util/src/main/java/org/key_project/util/java/package-info.java index d07419ac987..19d34270142 100644 --- a/key.util/src/main/java/org/key_project/util/java/package-info.java +++ b/key.util/src/main/java/org/key_project/util/java/package-info.java @@ -2,6 +2,7 @@ * @author Alexander Weigl * @version 1 (24.07.23) */ -@NullMarked package org.key_project.util.java; +@NullMarked +package org.key_project.util.java; -import org.jspecify.annotations.NullMarked; \ No newline at end of file +import org.jspecify.annotations.NullMarked; diff --git a/key.util/src/main/java/org/key_project/util/java/thread/IRunnableWithException.java b/key.util/src/main/java/org/key_project/util/java/thread/IRunnableWithException.java index 19bfa289adf..225529b70c9 100644 --- a/key.util/src/main/java/org/key_project/util/java/thread/IRunnableWithException.java +++ b/key.util/src/main/java/org/key_project/util/java/thread/IRunnableWithException.java @@ -24,5 +24,6 @@ public interface IRunnableWithException extends Runnable { * * @return An occurred exception. */ - @Nullable Exception getException(); + @Nullable + Exception getException(); } diff --git a/key.util/src/main/java/org/key_project/util/java/thread/IRunnableWithResult.java b/key.util/src/main/java/org/key_project/util/java/thread/IRunnableWithResult.java index 4234c017bad..d9516fd9392 100644 --- a/key.util/src/main/java/org/key_project/util/java/thread/IRunnableWithResult.java +++ b/key.util/src/main/java/org/key_project/util/java/thread/IRunnableWithResult.java @@ -24,12 +24,14 @@ public interface IRunnableWithResult extends IRunnableWithException { * * @return The result. */ - @Nullable T getResult(); + @Nullable + T getResult(); /** * Returns an occurred exception. * * @return An occurred exception. */ - @Nullable Exception getException(); + @Nullable + Exception getException(); } diff --git a/key.util/src/main/java/org/key_project/util/java/thread/package-info.java b/key.util/src/main/java/org/key_project/util/java/thread/package-info.java index 5d90f9ce6bb..4b58f90e8e6 100644 --- a/key.util/src/main/java/org/key_project/util/java/thread/package-info.java +++ b/key.util/src/main/java/org/key_project/util/java/thread/package-info.java @@ -2,6 +2,7 @@ * @author Alexander Weigl * @version 1 (24.07.23) */ -@NullMarked package org.key_project.util.java.thread; +@NullMarked +package org.key_project.util.java.thread; -import org.jspecify.annotations.NullMarked; \ No newline at end of file +import org.jspecify.annotations.NullMarked; diff --git a/key.util/src/main/java/org/key_project/util/package-info.java b/key.util/src/main/java/org/key_project/util/package-info.java index 7f5c80ce71b..5a4916969b6 100644 --- a/key.util/src/main/java/org/key_project/util/package-info.java +++ b/key.util/src/main/java/org/key_project/util/package-info.java @@ -2,6 +2,7 @@ * @author Alexander Weigl * @version 1 (24.07.23) */ -@NullMarked package org.key_project.util; +@NullMarked +package org.key_project.util; -import org.jspecify.annotations.NullMarked; \ No newline at end of file +import org.jspecify.annotations.NullMarked; diff --git a/key.util/src/main/java/org/key_project/util/reflection/ClassLoaderUtil.java b/key.util/src/main/java/org/key_project/util/reflection/ClassLoaderUtil.java index d9d54dbb4e7..900444cd97b 100644 --- a/key.util/src/main/java/org/key_project/util/reflection/ClassLoaderUtil.java +++ b/key.util/src/main/java/org/key_project/util/reflection/ClassLoaderUtil.java @@ -3,10 +3,10 @@ * SPDX-License-Identifier: GPL-2.0-only */ package org.key_project.util.reflection; -import org.jspecify.annotations.NullMarked; - import java.util.ServiceLoader; +import org.jspecify.annotations.NullMarked; + /** * This class provides utility methods to load classes at runtime which works in all supported * application types: diff --git a/key.util/src/main/java/org/key_project/util/reflection/IClassLoader.java b/key.util/src/main/java/org/key_project/util/reflection/IClassLoader.java index 09d09bea16e..ca2d2192e2f 100644 --- a/key.util/src/main/java/org/key_project/util/reflection/IClassLoader.java +++ b/key.util/src/main/java/org/key_project/util/reflection/IClassLoader.java @@ -3,10 +3,10 @@ * SPDX-License-Identifier: GPL-2.0-only */ package org.key_project.util.reflection; -import org.jspecify.annotations.NullMarked; - import java.util.ServiceLoader; +import org.jspecify.annotations.NullMarked; + /** * Instances of this class allow to access {@link Class}es at runtime in a special application type. *

diff --git a/key.util/src/main/java/org/key_project/util/reflection/JavaApplicationClassLoader.java b/key.util/src/main/java/org/key_project/util/reflection/JavaApplicationClassLoader.java index 8b72c2df0f6..39fa57f6204 100644 --- a/key.util/src/main/java/org/key_project/util/reflection/JavaApplicationClassLoader.java +++ b/key.util/src/main/java/org/key_project/util/reflection/JavaApplicationClassLoader.java @@ -3,10 +3,10 @@ * SPDX-License-Identifier: GPL-2.0-only */ package org.key_project.util.reflection; -import org.jspecify.annotations.NullMarked; - import java.util.ServiceLoader; +import org.jspecify.annotations.NullMarked; + /** * An {@link IClassLoader} implementation for Java Applications. *

diff --git a/key.util/src/main/java/org/key_project/util/testcategories/package-info.java b/key.util/src/main/java/org/key_project/util/testcategories/package-info.java index f002a231713..31b3f4f9f6e 100644 --- a/key.util/src/main/java/org/key_project/util/testcategories/package-info.java +++ b/key.util/src/main/java/org/key_project/util/testcategories/package-info.java @@ -10,4 +10,4 @@ @NullMarked package org.key_project.util.testcategories; -import org.jspecify.annotations.NullMarked; \ No newline at end of file +import org.jspecify.annotations.NullMarked; diff --git a/key.util/src/test/java/org/key_project/util/model/ClassA.java b/key.util/src/test/java/org/key_project/util/model/ClassA.java index 17e84c4bf51..97483d79cc0 100644 --- a/key.util/src/test/java/org/key_project/util/model/ClassA.java +++ b/key.util/src/test/java/org/key_project/util/model/ClassA.java @@ -3,7 +3,7 @@ * SPDX-License-Identifier: GPL-2.0-only */ package org.key_project.util.model; -@SuppressWarnings({"unused", "nullness"}) +@SuppressWarnings({ "unused", "nullness" }) public class ClassA { private final int privateField = 1; diff --git a/keyext.exploration/src/main/java/org/key_project/exploration/ExplorationExtension.java b/keyext.exploration/src/main/java/org/key_project/exploration/ExplorationExtension.java index cf7d16a0fd6..9cf157ad606 100644 --- a/keyext.exploration/src/main/java/org/key_project/exploration/ExplorationExtension.java +++ b/keyext.exploration/src/main/java/org/key_project/exploration/ExplorationExtension.java @@ -8,7 +8,6 @@ import java.util.Collection; import java.util.Collections; import java.util.List; -import org.jspecify.annotations.NonNull; import javax.swing.*; import de.uka.ilkd.key.core.KeYMediator; @@ -34,6 +33,8 @@ import org.key_project.exploration.actions.*; import org.key_project.exploration.ui.ExplorationStepsList; +import org.jspecify.annotations.NonNull; + /** * Entry point for the Proof Exploration Extension. * diff --git a/keyext.exploration/src/main/java/org/key_project/exploration/ExplorationModeModel.java b/keyext.exploration/src/main/java/org/key_project/exploration/ExplorationModeModel.java index f009616a3a7..3ef79c2ff5c 100644 --- a/keyext.exploration/src/main/java/org/key_project/exploration/ExplorationModeModel.java +++ b/keyext.exploration/src/main/java/org/key_project/exploration/ExplorationModeModel.java @@ -8,7 +8,6 @@ import java.util.Map; import java.util.WeakHashMap; import java.util.concurrent.atomic.AtomicInteger; -import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.gui.MainWindow; import de.uka.ilkd.key.gui.prooftree.GUIProofTreeModel; diff --git a/keyext.exploration/src/main/java/org/key_project/exploration/ExplorationNodeData.java b/keyext.exploration/src/main/java/org/key_project/exploration/ExplorationNodeData.java index 6422c77b93c..b86ee6fa7ae 100644 --- a/keyext.exploration/src/main/java/org/key_project/exploration/ExplorationNodeData.java +++ b/keyext.exploration/src/main/java/org/key_project/exploration/ExplorationNodeData.java @@ -4,11 +4,12 @@ package org.key_project.exploration; import java.util.Objects; -import org.jspecify.annotations.NonNull; -import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.proof.Node; +import org.jspecify.annotations.NonNull; +import org.jspecify.annotations.Nullable; + /** * Information on exploration that is attached to nodes. If such an object is attached to a node, * this node will be highlighted in the tree with a border and if an ExplorationAction is set this diff --git a/keyext.exploration/src/main/java/org/key_project/exploration/ProofExplorationService.java b/keyext.exploration/src/main/java/org/key_project/exploration/ProofExplorationService.java index 1506784e4c2..8a2c9027d8a 100644 --- a/keyext.exploration/src/main/java/org/key_project/exploration/ProofExplorationService.java +++ b/keyext.exploration/src/main/java/org/key_project/exploration/ProofExplorationService.java @@ -4,8 +4,6 @@ package org.key_project.exploration; import java.util.Objects; -import org.jspecify.annotations.NonNull; -import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.core.KeYMediator; import de.uka.ilkd.key.java.Services; @@ -19,6 +17,9 @@ import org.key_project.util.collection.ImmutableList; +import org.jspecify.annotations.NonNull; +import org.jspecify.annotations.Nullable; + /** * ExplorationAction that handles the addition of formulas to the sequent. This action is * implemented using the cut rule. diff --git a/keyext.exploration/src/main/java/org/key_project/exploration/actions/AddFormulaToAntecedentAction.java b/keyext.exploration/src/main/java/org/key_project/exploration/actions/AddFormulaToAntecedentAction.java index 807951536fa..d0b34250534 100644 --- a/keyext.exploration/src/main/java/org/key_project/exploration/actions/AddFormulaToAntecedentAction.java +++ b/keyext.exploration/src/main/java/org/key_project/exploration/actions/AddFormulaToAntecedentAction.java @@ -4,7 +4,6 @@ package org.key_project.exploration.actions; import java.awt.event.ActionEvent; -import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.gui.MainWindow; import de.uka.ilkd.key.logic.Term; @@ -12,6 +11,8 @@ import org.key_project.exploration.ProofExplorationService; +import org.jspecify.annotations.NonNull; + /** * @author Alexander Weigl * @author Sarah Grebing diff --git a/keyext.exploration/src/main/java/org/key_project/exploration/actions/AddFormulaToSuccedentAction.java b/keyext.exploration/src/main/java/org/key_project/exploration/actions/AddFormulaToSuccedentAction.java index 7fc4531da91..9c82697f90d 100644 --- a/keyext.exploration/src/main/java/org/key_project/exploration/actions/AddFormulaToSuccedentAction.java +++ b/keyext.exploration/src/main/java/org/key_project/exploration/actions/AddFormulaToSuccedentAction.java @@ -4,7 +4,6 @@ package org.key_project.exploration.actions; import java.awt.event.ActionEvent; -import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.gui.MainWindow; import de.uka.ilkd.key.logic.Term; @@ -12,6 +11,8 @@ import org.key_project.exploration.ProofExplorationService; +import org.jspecify.annotations.NonNull; + /** * @author Alexander Weigl * @author Sarah Grebing diff --git a/keyext.exploration/src/main/java/org/key_project/exploration/ui/ExplorationStepsList.java b/keyext.exploration/src/main/java/org/key_project/exploration/ui/ExplorationStepsList.java index f7558c54a29..4beb188f012 100644 --- a/keyext.exploration/src/main/java/org/key_project/exploration/ui/ExplorationStepsList.java +++ b/keyext.exploration/src/main/java/org/key_project/exploration/ui/ExplorationStepsList.java @@ -7,8 +7,6 @@ import java.awt.event.ActionEvent; import java.util.*; import java.util.List; -import org.jspecify.annotations.NonNull; -import org.jspecify.annotations.Nullable; import javax.swing.*; import javax.swing.tree.*; @@ -26,6 +24,8 @@ import org.key_project.exploration.Icons; import bibliothek.gui.dock.common.action.CAction; +import org.jspecify.annotations.NonNull; +import org.jspecify.annotations.Nullable; /** * A view that summaries the exploration steps inside a proof. diff --git a/keyext.slicing/src/main/java/org/key_project/slicing/SlicingExtension.java b/keyext.slicing/src/main/java/org/key_project/slicing/SlicingExtension.java index 0c866c220b9..3fac0c5c8c4 100644 --- a/keyext.slicing/src/main/java/org/key_project/slicing/SlicingExtension.java +++ b/keyext.slicing/src/main/java/org/key_project/slicing/SlicingExtension.java @@ -9,7 +9,6 @@ import java.util.IdentityHashMap; import java.util.List; import java.util.Map; -import org.jspecify.annotations.NonNull; import javax.swing.*; import de.uka.ilkd.key.core.KeYMediator; @@ -33,6 +32,8 @@ import org.key_project.slicing.ui.ShowGraphAction; import org.key_project.slicing.ui.SlicingLeftPanel; +import org.jspecify.annotations.NonNull; + /** * Proof slicing extension. * For more details see the user diff --git a/keyext.slicing/src/main/java/org/key_project/slicing/ui/SlicingLeftPanel.java b/keyext.slicing/src/main/java/org/key_project/slicing/ui/SlicingLeftPanel.java index 98adf3b869e..bcb1cf29eec 100644 --- a/keyext.slicing/src/main/java/org/key_project/slicing/ui/SlicingLeftPanel.java +++ b/keyext.slicing/src/main/java/org/key_project/slicing/ui/SlicingLeftPanel.java @@ -15,7 +15,6 @@ import java.util.List; import java.util.Optional; import java.util.stream.Collectors; -import org.jspecify.annotations.NonNull; import javax.swing.*; import javax.swing.border.TitledBorder; @@ -45,6 +44,7 @@ import org.key_project.slicing.util.GraphvizDotExecutor; import bibliothek.gui.dock.common.action.CAction; +import org.jspecify.annotations.NonNull; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/keyext.ui.testgen/src/main/java/de/uka/ilkd/key/gui/testgen/TestgenExtension.java b/keyext.ui.testgen/src/main/java/de/uka/ilkd/key/gui/testgen/TestgenExtension.java index 79d8210b6fb..a870a2441d4 100644 --- a/keyext.ui.testgen/src/main/java/de/uka/ilkd/key/gui/testgen/TestgenExtension.java +++ b/keyext.ui.testgen/src/main/java/de/uka/ilkd/key/gui/testgen/TestgenExtension.java @@ -8,7 +8,6 @@ import java.util.Collection; import java.util.Collections; import java.util.List; -import org.jspecify.annotations.NonNull; import javax.swing.*; import de.uka.ilkd.key.core.KeYMediator; @@ -19,6 +18,8 @@ import de.uka.ilkd.key.gui.settings.SettingsProvider; import de.uka.ilkd.key.macros.TestGenMacro; +import org.jspecify.annotations.NonNull; + /** * @author Alexander Weigl * @version 1 (9/16/20) From 266f753b9906113e48be2eaa0c71c5fee4f20c87 Mon Sep 17 00:00:00 2001 From: Florian Lanzinger Date: Wed, 8 Nov 2023 19:54:37 +0100 Subject: [PATCH 24/37] Fix compile errors --- .../uka/ilkd/key/nparser/ParsingFacade.java | 19 ++------ .../java/de/uka/ilkd/key/proof/Proof.java | 44 +------------------ .../key/speclang/jml/JMLInfoExtractor.java | 10 ++--- .../java/org/key_project/util/Strings.java | 8 ++-- .../util/collection/IdentityHashSet.java | 18 +++++--- .../util/collection/ImmutableSLList.java | 2 +- 6 files changed, 27 insertions(+), 74 deletions(-) diff --git a/key.core/src/main/java/de/uka/ilkd/key/nparser/ParsingFacade.java b/key.core/src/main/java/de/uka/ilkd/key/nparser/ParsingFacade.java index a226fbe58b5..a3af701c7b3 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/nparser/ParsingFacade.java +++ b/key.core/src/main/java/de/uka/ilkd/key/nparser/ParsingFacade.java @@ -13,9 +13,6 @@ import java.nio.charset.CodingErrorAction; import java.nio.file.Path; import java.util.*; -import org.jspecify.annotations.NonNull; -import org.jspecify.annotations.NullMarked; -import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.nparser.builder.ChoiceFinder; import de.uka.ilkd.key.proof.io.RuleSource; @@ -27,6 +24,10 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.jspecify.annotations.NonNull; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; + /** * This facade provides low-level access to the ANTLR4 Parser and Lexer. *

@@ -52,12 +53,8 @@ private ParsingFacade() { * @param parse tree type * @return the {@link ParserRuleContext} inside the given ast object. */ -<<<<<<< HEAD - public static T getParseRuleContext(KeyAst ast) { -======= @NonNull public static T getParseRuleContext(@NonNull KeyAst ast) { ->>>>>>> upstream/main return ast.ctx; } @@ -87,11 +84,7 @@ public static List parseFiles(URL url) throws IOException { * * @param ctxs non-null list */ -<<<<<<< HEAD - public static ChoiceInformation getChoices(List ctxs) { -======= public static @NonNull ChoiceInformation getChoices(@NonNull List ctxs) { ->>>>>>> upstream/main ChoiceInformation ci = new ChoiceInformation(); ChoiceFinder finder = new ChoiceFinder(ci); ctxs.forEach(it -> it.accept(finder)); @@ -175,12 +168,8 @@ public static KeyAst.Seq parseSequent(CharStream stream) { * @param ctx non-null context * @return non-null string */ -<<<<<<< HEAD - public static String getValueDocumentation(KeYParser.String_valueContext ctx) { -======= public static @NonNull String getValueDocumentation( KeYParser.@NonNull String_valueContext ctx) { ->>>>>>> upstream/main return ctx.getText().substring(1, ctx.getText().length() - 1).replace("\\\"", "\"") .replace("\\\\", "\\"); } diff --git a/key.core/src/main/java/de/uka/ilkd/key/proof/Proof.java b/key.core/src/main/java/de/uka/ilkd/key/proof/Proof.java index e5b9e9dc279..329474c0f4d 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/proof/Proof.java +++ b/key.core/src/main/java/de/uka/ilkd/key/proof/Proof.java @@ -9,12 +9,6 @@ import java.util.*; import java.util.function.Consumer; import java.util.function.Predicate; -<<<<<<< HEAD -import org.jspecify.annotations.NonNull; -import org.jspecify.annotations.NullMarked; -import org.jspecify.annotations.Nullable; -======= ->>>>>>> upstream/main import javax.swing.*; import de.uka.ilkd.key.java.JavaInfo; @@ -49,6 +43,7 @@ import org.jspecify.annotations.NonNull; import org.jspecify.annotations.Nullable; +import org.jspecify.annotations.NullMarked; /** @@ -235,35 +230,8 @@ private Proof(String name, Sequent problem, TacletIndex rules, BuiltInRuleIndex this(new Name(name), initConfig); final var rootNode = new Node(this, problem); - -<<<<<<< HEAD - register(new ProofJavaSourceCollection(), ProofJavaSourceCollection.class); - var rootNode = new Node(this, problem); - var sources = lookup(ProofJavaSourceCollection.class); - - rootNode.sequent().forEach(formula -> { - OriginTermLabel originLabel = - (OriginTermLabel) formula.formula().getLabel(OriginTermLabel.NAME); - if (originLabel != null) { - if (originLabel.getOrigin() instanceof FileOrigin) { - ((FileOrigin) originLabel.getOrigin()) - .getFileName() - .ifPresent(sources::addRelevantFile); - } - - originLabel.getSubtermOrigins().stream() - .filter(o -> o instanceof FileOrigin) - .map(o -> (FileOrigin) o) - .forEach(o -> o.getFileName().ifPresent(sources::addRelevantFile)); - } - }); - - var firstGoal = - new Goal(rootNode, rules, new BuiltInRuleAppIndex(builtInRules), getServices()); -======= final var firstGoal = new Goal(rootNode, rules, new BuiltInRuleAppIndex(builtInRules), getServices()); ->>>>>>> upstream/main openGoals = openGoals.prepend(firstGoal); setRoot(rootNode); @@ -743,13 +711,7 @@ public ImmutableList prune(final Node cuttingPoint) { } // Merge rule applications: Unlink all merge partners. -<<<<<<< HEAD - if (visitedNode.getAppliedRuleApp() instanceof MergeRuleBuiltInRuleApp) { - final MergeRuleBuiltInRuleApp mergeApp = - (MergeRuleBuiltInRuleApp) visitedNode.getAppliedRuleApp(); -======= if (visitedNode.getAppliedRuleApp() instanceof MergeRuleBuiltInRuleApp mergeApp) { ->>>>>>> upstream/main for (MergePartner mergePartner : mergeApp.getMergePartners()) { final Goal linkedGoal = mergePartner.getGoal(); @@ -768,11 +730,7 @@ public ImmutableList prune(final Node cuttingPoint) { // first leaf is closed -> add as goal and reopen final Goal firstGoal = -<<<<<<< HEAD - firstLeaf.isClosed() ? getClosedGoal(firstLeaf) : getGoal(firstLeaf); -======= firstLeaf.isClosed() ? getClosedGoal(firstLeaf) : getOpenGoal(firstLeaf); ->>>>>>> upstream/main assert firstGoal != null; if (firstLeaf.isClosed()) { reOpenGoal(firstGoal); diff --git a/key.core/src/main/java/de/uka/ilkd/key/speclang/jml/JMLInfoExtractor.java b/key.core/src/main/java/de/uka/ilkd/key/speclang/jml/JMLInfoExtractor.java index 8723dfb7833..41167b54bb1 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/speclang/jml/JMLInfoExtractor.java +++ b/key.core/src/main/java/de/uka/ilkd/key/speclang/jml/JMLInfoExtractor.java @@ -3,9 +3,6 @@ * SPDX-License-Identifier: GPL-2.0-only */ package de.uka.ilkd.key.speclang.jml; -import org.jspecify.annotations.NonNull; -import org.jspecify.annotations.Nullable; - import de.uka.ilkd.key.java.Comment; import de.uka.ilkd.key.java.abstraction.KeYJavaType; import de.uka.ilkd.key.java.declaration.*; @@ -17,6 +14,9 @@ import org.key_project.util.collection.ImmutableList; import org.key_project.util.collection.ImmutableSLList; +import org.jspecify.annotations.NonNull; +import org.jspecify.annotations.Nullable; + /** * Helper class used by the JML translation. Provides methods that look for certain keywords (such * as "pure") in comments, and that help in desugaring such keywords. @@ -408,11 +408,7 @@ public static SpecMathMode getSpecMathModeOrDefault(@NonNull KeYJavaType t) { */ @Nullable public static SpecMathMode getSpecMathMode(@NonNull IProgramMethod pm) { -<<<<<<< HEAD - var methodMode = pm.getMethodDeclaration().getJmlModifiers().specMathMode; -======= var methodMode = pm.getMethodDeclaration().getJmlModifiers().specMathMode(); ->>>>>>> upstream/main return methodMode != null ? methodMode : getSpecMathMode(pm.getContainerType()); } diff --git a/key.util/src/main/java/org/key_project/util/Strings.java b/key.util/src/main/java/org/key_project/util/Strings.java index c3239441ba2..3464f1aed44 100644 --- a/key.util/src/main/java/org/key_project/util/Strings.java +++ b/key.util/src/main/java/org/key_project/util/Strings.java @@ -3,12 +3,14 @@ * SPDX-License-Identifier: GPL-2.0-only */ package org.key_project.util; +import java.util.Objects; import java.util.function.Function; import java.util.stream.Collectors; import java.util.stream.StreamSupport; import org.key_project.util.java.StringUtil; +import org.jspecify.annotations.Nullable; import org.jspecify.annotations.NullMarked; /** @@ -50,11 +52,11 @@ public static boolean isJMLComment(String comment) { * @return the CharSequence in the described format * @param the type of the elements of the iterated collection */ - public static String formatAsList(Iterable it, + public static String formatAsList(Iterable it, CharSequence open, CharSequence sep, CharSequence close, Function mapper) { return StreamSupport.stream(it.spliterator(), false) - .map(a -> mapper.apply(a).toString()) + .map(a -> Objects.toString(mapper.apply(a))) .collect(Collectors.joining(sep, open, close)); } @@ -69,7 +71,7 @@ public static String formatAsList(Iterable it, * @return the CharSequence in the described format * @param the type of the elements of the iterated collection */ - public static String formatAsList(Iterable it, + public static String formatAsList(Iterable it, CharSequence open, CharSequence sep, CharSequence close) { return formatAsList(it, open, sep, close, Function.identity()); } diff --git a/key.util/src/main/java/org/key_project/util/collection/IdentityHashSet.java b/key.util/src/main/java/org/key_project/util/collection/IdentityHashSet.java index 0c4d1408f30..2289de287e9 100644 --- a/key.util/src/main/java/org/key_project/util/collection/IdentityHashSet.java +++ b/key.util/src/main/java/org/key_project/util/collection/IdentityHashSet.java @@ -8,17 +8,21 @@ import java.util.Iterator; import java.util.Set; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; + /** * Hash set using the object's identity instead of their hashcode to determine uniqueness. * * @param elmeent type * @author Arne Keller */ -public class IdentityHashSet implements Set { +@NullMarked +public final class IdentityHashSet implements Set { /** * Backing store. */ - private final IdentityHashMap innerMap = new IdentityHashMap<>(); + private final IdentityHashMap innerMap = new IdentityHashMap<>(); /** * Construct an empty set. @@ -47,7 +51,7 @@ public boolean isEmpty() { } @Override - public boolean contains(Object o) { + public boolean contains(@Nullable Object o) { return innerMap.containsKey(o); } @@ -56,11 +60,13 @@ public Iterator iterator() { return innerMap.keySet().iterator(); } + @SuppressWarnings("nullness") // see https://checkerframework.org/manual/#nullness-collection-toarray @Override - public Object[] toArray() { + public @Nullable Object [] toArray() { return innerMap.keySet().toArray(); } + @SuppressWarnings("nullness") // see https://checkerframework.org/manual/#nullness-collection-toarray @Override public T1[] toArray(T1[] a) { return innerMap.keySet().toArray(a); @@ -72,7 +78,7 @@ public boolean add(T o) { } @Override - public boolean remove(Object o) { + public boolean remove(@Nullable Object o) { var contained = innerMap.containsKey(o); innerMap.remove(o); return contained; @@ -101,6 +107,8 @@ public boolean removeAll(Collection c) { return changed; } + + @Override public boolean retainAll(Collection c) { return innerMap.keySet().retainAll(c); diff --git a/key.util/src/main/java/org/key_project/util/collection/ImmutableSLList.java b/key.util/src/main/java/org/key_project/util/collection/ImmutableSLList.java index cb9d28b2c4a..9cc1e5781bd 100644 --- a/key.util/src/main/java/org/key_project/util/collection/ImmutableSLList.java +++ b/key.util/src/main/java/org/key_project/util/collection/ImmutableSLList.java @@ -302,7 +302,7 @@ public boolean exists(Predicate predicate) { */ @Override public ImmutableList append(S e) { - return new Cons<>(e).prepend(this); + return new Cons(e).prepend(this); } /** From 860c5e15a8d38d46b189651d97b838fadfc817f7 Mon Sep 17 00:00:00 2001 From: Florian Lanzinger Date: Wed, 8 Nov 2023 20:28:02 +0100 Subject: [PATCH 25/37] Add readme to key.util --- key.util/Readme.md | 104 ++++++++++++++++++ .../util/collection/IdentityHashSet.java | 6 +- 2 files changed, 106 insertions(+), 4 deletions(-) create mode 100644 key.util/Readme.md diff --git a/key.util/Readme.md b/key.util/Readme.md new file mode 100644 index 00000000000..284b87182ae --- /dev/null +++ b/key.util/Readme.md @@ -0,0 +1,104 @@ +# key.util + +This subproject contains various data structures and utility functions +used by the KeY project. + +## Nullness checking + +This subproject uses the EISOP branch of the Checker Framework +(https://eisop.github.io/) to check for nullness-related +errors at compile time. + +Any use of a type is considered to be `@NonNull` by default unless `@Nullable` +is specified. E.g., a variable of type `@Nullable Object` cannot be assigned +to a variable of type `@NonNull Object`. + +This is for the most part intuitive, but arrays and generics require some +explanation: +For an array, we specify the nullability of both the array and elements. +E.g., `@Nullable String @NonNull []` is a non-null array of nullable strings. +The nullability of a generic type is determined by its bounds. E.g., if we +have a class `class A`, then any use of `T` in `A` +is implicitly nullable; but if we have a class `class B`, then any use of +`S` in `B` is implicitly non-null because this is the default bound. + +For further details, see +https://jspecify.dev/docs/api/org/jspecify/annotations/package-summary.html +and +https://eisop.github.io/cf/manual/manual.html#nullness-checker + +## Initialization checking + +The Checker Framework also checks for initialization: If a constructor does +not initialize every `@NonNull` field with a non-null value, an error to that +effect is reported at compile time. If a constructor tries to call a non-helper +method, an error is also reported, as that method may rely on all `@NonNull` +being initialized. +You can mark a method as helper by specifying +`@UnderInitialization(InitClass.class) ReceiverClass this` as the first +parameter, where `ReceiverClass` is the name of the current class, and +`InitClass` is the class up to which `this` should be initialized before +the method is allowed to be called. +If you want to allow the helper method being called even after `this` has been +further initialized, use `@UnknownInitialization(InitClass.class)` instead. +Within a helper method, all possibly uninitialized fields are considered +`@Nullable` even if declared as `@NonNull`. + +E.g., consider the following listing. + +```java +class A { + @NonNull Object fieldA; + + A() { + fieldA = new Object(); + } +} + +class B extends A { + @NonNull Object fieldB; + + B() { + super(); + // Allowed because the super constructor has initialized this up to A + helperA(); + + // Not allowed because this is not yet initialized up to B + helperB(); + + fieldB = new Object(); + + // Allowed now because fieldB was just initialized + helper1(); + + // Not allowed because B is not final; thus there may be a subclass + // for which this has not yet been initialized. + nonHelper(); + } + + void helperA(@UnderInitialization(A.class) B this) { + // Allowed because this is initialized up to A; + // thus fieldA is @NonNull + fieldA.hashCode(); + // Not allowed because this is not initialized up to B; + // thus fieldB is @Nullable + fieldB.hashCode(); + } + + void helperB(@UnderInitialization(B.class) B this) { + // Both allowed because this is initialized up to B + fieldA.hashCode(); + fieldB.hashCode(); + } + + void nonHelper() { + // ... + } +} +``` + +The initialization types for arrays and generics are specified in the same way +as for nullness types. + +For more details, see +https://eisop.github.io/cf/manual/manual.html#initialization-checker \ No newline at end of file diff --git a/key.util/src/main/java/org/key_project/util/collection/IdentityHashSet.java b/key.util/src/main/java/org/key_project/util/collection/IdentityHashSet.java index 2289de287e9..315f8da7162 100644 --- a/key.util/src/main/java/org/key_project/util/collection/IdentityHashSet.java +++ b/key.util/src/main/java/org/key_project/util/collection/IdentityHashSet.java @@ -8,7 +8,6 @@ import java.util.Iterator; import java.util.Set; -import org.jspecify.annotations.NullMarked; import org.jspecify.annotations.Nullable; /** @@ -17,7 +16,6 @@ * @param elmeent type * @author Arne Keller */ -@NullMarked public final class IdentityHashSet implements Set { /** * Backing store. @@ -60,13 +58,13 @@ public Iterator iterator() { return innerMap.keySet().iterator(); } - @SuppressWarnings("nullness") // see https://checkerframework.org/manual/#nullness-collection-toarray + @SuppressWarnings("nullness") // see https://eisop.github.io/cf/manual/manual.html#nullness-collection-toarray @Override public @Nullable Object [] toArray() { return innerMap.keySet().toArray(); } - @SuppressWarnings("nullness") // see https://checkerframework.org/manual/#nullness-collection-toarray + @SuppressWarnings("nullness") // see https://eisop.github.io/cf/manual/manual.html#nullness-collection-toarray @Override public T1[] toArray(T1[] a) { return innerMap.keySet().toArray(a); From 3f3c801404d3ee60c4ed7d20363fb11acbef178f Mon Sep 17 00:00:00 2001 From: Florian Lanzinger Date: Wed, 8 Nov 2023 20:28:21 +0100 Subject: [PATCH 26/37] Remove unnecessary @NullMarked annotations in @NullMarked packages --- key.util/src/main/java/org/key_project/util/ExtList.java | 3 --- key.util/src/main/java/org/key_project/util/Filenames.java | 3 --- key.util/src/main/java/org/key_project/util/LRUCache.java | 3 --- key.util/src/main/java/org/key_project/util/Strings.java | 2 -- key.util/src/main/java/org/key_project/util/bean/Bean.java | 2 -- key.util/src/main/java/org/key_project/util/bean/IBean.java | 3 --- .../src/main/java/org/key_project/util/bean/package-info.java | 4 ++++ .../org/key_project/util/collection/DefaultImmutableSet.java | 2 -- .../java/org/key_project/util/collection/ImmutableList.java | 2 -- .../java/org/key_project/util/collection/ImmutableSLList.java | 3 --- .../java/org/key_project/util/collection/ImmutableSet.java | 3 --- .../util/java/thread/AbstractRunnableWithException.java | 2 -- .../util/java/thread/AbstractRunnableWithResult.java | 2 -- .../key_project/util/java/thread/IRunnableWithException.java | 2 -- .../org/key_project/util/java/thread/IRunnableWithResult.java | 2 -- .../java/org/key_project/util/reflection/ClassLoaderUtil.java | 3 --- .../java/org/key_project/util/reflection/IClassLoader.java | 3 --- .../util/reflection/JavaApplicationClassLoader.java | 3 --- .../java/org/key_project/util/reflection/package-info.java | 4 ++++ 19 files changed, 8 insertions(+), 43 deletions(-) create mode 100644 key.util/src/main/java/org/key_project/util/bean/package-info.java create mode 100644 key.util/src/main/java/org/key_project/util/reflection/package-info.java diff --git a/key.util/src/main/java/org/key_project/util/ExtList.java b/key.util/src/main/java/org/key_project/util/ExtList.java index 9cfb09fdaef..319cc12386a 100644 --- a/key.util/src/main/java/org/key_project/util/ExtList.java +++ b/key.util/src/main/java/org/key_project/util/ExtList.java @@ -7,15 +7,12 @@ import java.util.Arrays; import java.util.Iterator; import java.util.LinkedList; - -import org.jspecify.annotations.NullMarked; import org.jspecify.annotations.Nullable; /** * Extends java.util.LinkedList in order to collect elements according to their type. * Has facilities to get elements of a certain type ({@link #get(Class)}, {@link #collect(Class)}). */ -@NullMarked public final class ExtList extends LinkedList { private static final long serialVersionUID = 9182017368310263908L; diff --git a/key.util/src/main/java/org/key_project/util/Filenames.java b/key.util/src/main/java/org/key_project/util/Filenames.java index d353d4f7ca4..9f0c7eb4e7d 100644 --- a/key.util/src/main/java/org/key_project/util/Filenames.java +++ b/key.util/src/main/java/org/key_project/util/Filenames.java @@ -8,13 +8,10 @@ import java.util.Arrays; import java.util.List; -import org.jspecify.annotations.NullMarked; - /** * @author Alexander Weigl * @version 1 (29.03.19) */ -@NullMarked public class Filenames { // ======================================================= // Methods operating on Strings diff --git a/key.util/src/main/java/org/key_project/util/LRUCache.java b/key.util/src/main/java/org/key_project/util/LRUCache.java index 39d8440e900..4042135ed57 100644 --- a/key.util/src/main/java/org/key_project/util/LRUCache.java +++ b/key.util/src/main/java/org/key_project/util/LRUCache.java @@ -6,12 +6,9 @@ import java.util.LinkedHashMap; import java.util.Map; -import org.jspecify.annotations.NullMarked; - /** * Simple realisation of an LRU cache. */ -@NullMarked public class LRUCache extends LinkedHashMap { /** diff --git a/key.util/src/main/java/org/key_project/util/Strings.java b/key.util/src/main/java/org/key_project/util/Strings.java index 3464f1aed44..a12bcdbf0dd 100644 --- a/key.util/src/main/java/org/key_project/util/Strings.java +++ b/key.util/src/main/java/org/key_project/util/Strings.java @@ -11,7 +11,6 @@ import org.key_project.util.java.StringUtil; import org.jspecify.annotations.Nullable; -import org.jspecify.annotations.NullMarked; /** * Helper functions for {@link String}s @@ -19,7 +18,6 @@ * @author Alexander Weigl * @version 1 (29.03.19) */ -@NullMarked public class Strings { /** * @deprecated This class has been merged with {@link org.key_project.util.java.StringUtil}. diff --git a/key.util/src/main/java/org/key_project/util/bean/Bean.java b/key.util/src/main/java/org/key_project/util/bean/Bean.java index e9cd54f0123..7c3a46c0391 100644 --- a/key.util/src/main/java/org/key_project/util/bean/Bean.java +++ b/key.util/src/main/java/org/key_project/util/bean/Bean.java @@ -9,7 +9,6 @@ import org.key_project.util.java.ArrayUtil; -import org.jspecify.annotations.NullMarked; import org.jspecify.annotations.Nullable; /** @@ -19,7 +18,6 @@ * @author Martin Hentschel * @see IBean */ -@NullMarked public class Bean implements IBean { /** * The used {@link PropertyChangeSupport}. diff --git a/key.util/src/main/java/org/key_project/util/bean/IBean.java b/key.util/src/main/java/org/key_project/util/bean/IBean.java index 5441ed172ee..aa80a3ae0d2 100644 --- a/key.util/src/main/java/org/key_project/util/bean/IBean.java +++ b/key.util/src/main/java/org/key_project/util/bean/IBean.java @@ -5,8 +5,6 @@ import java.beans.PropertyChangeListener; -import org.jspecify.annotations.NullMarked; - /** *

* Defines the methods that a Java bean must have. @@ -18,7 +16,6 @@ * @author Martin Hentschel * @see Bean */ -@NullMarked public interface IBean { /** * Adds the given listener. diff --git a/key.util/src/main/java/org/key_project/util/bean/package-info.java b/key.util/src/main/java/org/key_project/util/bean/package-info.java new file mode 100644 index 00000000000..0cf610b9f7b --- /dev/null +++ b/key.util/src/main/java/org/key_project/util/bean/package-info.java @@ -0,0 +1,4 @@ +@NullMarked +package org.key_project.util.bean; + +import org.jspecify.annotations.NullMarked; diff --git a/key.util/src/main/java/org/key_project/util/collection/DefaultImmutableSet.java b/key.util/src/main/java/org/key_project/util/collection/DefaultImmutableSet.java index a4538d73600..70c0580ae60 100644 --- a/key.util/src/main/java/org/key_project/util/collection/DefaultImmutableSet.java +++ b/key.util/src/main/java/org/key_project/util/collection/DefaultImmutableSet.java @@ -12,7 +12,6 @@ import org.key_project.util.Strings; -import org.jspecify.annotations.NullMarked; import org.jspecify.annotations.Nullable; /** @@ -21,7 +20,6 @@ * * @param type of object to store */ -@NullMarked public class DefaultImmutableSet implements ImmutableSet { /** diff --git a/key.util/src/main/java/org/key_project/util/collection/ImmutableList.java b/key.util/src/main/java/org/key_project/util/collection/ImmutableList.java index 7c2eab4c14c..b46809d980a 100644 --- a/key.util/src/main/java/org/key_project/util/collection/ImmutableList.java +++ b/key.util/src/main/java/org/key_project/util/collection/ImmutableList.java @@ -10,13 +10,11 @@ import java.util.stream.Stream; import java.util.stream.StreamSupport; -import org.jspecify.annotations.NullMarked; import org.jspecify.annotations.Nullable; /** * List interface to be implemented by non-destructive lists */ -@NullMarked public interface ImmutableList extends Iterable, java.io.Serializable { diff --git a/key.util/src/main/java/org/key_project/util/collection/ImmutableSLList.java b/key.util/src/main/java/org/key_project/util/collection/ImmutableSLList.java index 9cc1e5781bd..7e52f453ee0 100644 --- a/key.util/src/main/java/org/key_project/util/collection/ImmutableSLList.java +++ b/key.util/src/main/java/org/key_project/util/collection/ImmutableSLList.java @@ -15,7 +15,6 @@ import org.key_project.util.Strings; import org.jspecify.annotations.NonNull; -import org.jspecify.annotations.NullMarked; import org.jspecify.annotations.Nullable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -30,9 +29,7 @@ * appending and prepending and element can be realized with O(1) costs (see Osaka) then having tail * and head with amortized O(1). This will be done later (if necessary). */ - @SuppressWarnings({ "unchecked" }) -@NullMarked public abstract class ImmutableSLList implements ImmutableList { /** diff --git a/key.util/src/main/java/org/key_project/util/collection/ImmutableSet.java b/key.util/src/main/java/org/key_project/util/collection/ImmutableSet.java index 9cf5f187cd9..ec69790c40d 100644 --- a/key.util/src/main/java/org/key_project/util/collection/ImmutableSet.java +++ b/key.util/src/main/java/org/key_project/util/collection/ImmutableSet.java @@ -9,15 +9,12 @@ import java.util.stream.Collector.Characteristics; import java.util.stream.Stream; -import org.jspecify.annotations.NullMarked; import org.jspecify.annotations.Nullable; /** * interface implemented by non-destructive Sets. CONVENTION: Each SetOf implementation has to * offer a public static final variable .nil() */ - -@NullMarked public interface ImmutableSet extends Iterable, java.io.Serializable { diff --git a/key.util/src/main/java/org/key_project/util/java/thread/AbstractRunnableWithException.java b/key.util/src/main/java/org/key_project/util/java/thread/AbstractRunnableWithException.java index df5172ee3aa..52b8bea53d7 100644 --- a/key.util/src/main/java/org/key_project/util/java/thread/AbstractRunnableWithException.java +++ b/key.util/src/main/java/org/key_project/util/java/thread/AbstractRunnableWithException.java @@ -4,7 +4,6 @@ package org.key_project.util.java.thread; import org.checkerframework.checker.nullness.qual.MonotonicNonNull; -import org.jspecify.annotations.NullMarked; import org.jspecify.annotations.Nullable; /** @@ -19,7 +18,6 @@ * @author Martin Hentschel * @see IRunnableWithResult */ -@NullMarked public abstract class AbstractRunnableWithException implements IRunnableWithException { /** * An occurred exception. diff --git a/key.util/src/main/java/org/key_project/util/java/thread/AbstractRunnableWithResult.java b/key.util/src/main/java/org/key_project/util/java/thread/AbstractRunnableWithResult.java index 4d85b1ff952..baa8c020edc 100644 --- a/key.util/src/main/java/org/key_project/util/java/thread/AbstractRunnableWithResult.java +++ b/key.util/src/main/java/org/key_project/util/java/thread/AbstractRunnableWithResult.java @@ -3,7 +3,6 @@ * SPDX-License-Identifier: GPL-2.0-only */ package org.key_project.util.java.thread; -import org.jspecify.annotations.NullMarked; import org.jspecify.annotations.Nullable; /** @@ -18,7 +17,6 @@ * @author Martin Hentschel * @see IRunnableWithResult */ -@NullMarked public abstract class AbstractRunnableWithResult extends AbstractRunnableWithException implements IRunnableWithResult { /** diff --git a/key.util/src/main/java/org/key_project/util/java/thread/IRunnableWithException.java b/key.util/src/main/java/org/key_project/util/java/thread/IRunnableWithException.java index 225529b70c9..ba59bdb00b3 100644 --- a/key.util/src/main/java/org/key_project/util/java/thread/IRunnableWithException.java +++ b/key.util/src/main/java/org/key_project/util/java/thread/IRunnableWithException.java @@ -3,7 +3,6 @@ * SPDX-License-Identifier: GPL-2.0-only */ package org.key_project.util.java.thread; -import org.jspecify.annotations.NullMarked; import org.jspecify.annotations.Nullable; /** @@ -17,7 +16,6 @@ * @author Martin Hentschel * @see AbstractRunnableWithException */ -@NullMarked public interface IRunnableWithException extends Runnable { /** * Returns an occurred exception. diff --git a/key.util/src/main/java/org/key_project/util/java/thread/IRunnableWithResult.java b/key.util/src/main/java/org/key_project/util/java/thread/IRunnableWithResult.java index d9516fd9392..31ee5a9ce68 100644 --- a/key.util/src/main/java/org/key_project/util/java/thread/IRunnableWithResult.java +++ b/key.util/src/main/java/org/key_project/util/java/thread/IRunnableWithResult.java @@ -3,7 +3,6 @@ * SPDX-License-Identifier: GPL-2.0-only */ package org.key_project.util.java.thread; -import org.jspecify.annotations.NullMarked; import org.jspecify.annotations.Nullable; /** @@ -17,7 +16,6 @@ * @author Martin Hentschel * @see AbstractRunnableWithResult */ -@NullMarked public interface IRunnableWithResult extends IRunnableWithException { /** * Returns the result. diff --git a/key.util/src/main/java/org/key_project/util/reflection/ClassLoaderUtil.java b/key.util/src/main/java/org/key_project/util/reflection/ClassLoaderUtil.java index 900444cd97b..66e6d26593d 100644 --- a/key.util/src/main/java/org/key_project/util/reflection/ClassLoaderUtil.java +++ b/key.util/src/main/java/org/key_project/util/reflection/ClassLoaderUtil.java @@ -5,8 +5,6 @@ import java.util.ServiceLoader; -import org.jspecify.annotations.NullMarked; - /** * This class provides utility methods to load classes at runtime which works in all supported * application types: @@ -40,7 +38,6 @@ * @see IClassLoader * @see JavaApplicationClassLoader */ -@NullMarked public class ClassLoaderUtil { /** * The {@link IClassLoader} instance to use. diff --git a/key.util/src/main/java/org/key_project/util/reflection/IClassLoader.java b/key.util/src/main/java/org/key_project/util/reflection/IClassLoader.java index ca2d2192e2f..f6014284b5d 100644 --- a/key.util/src/main/java/org/key_project/util/reflection/IClassLoader.java +++ b/key.util/src/main/java/org/key_project/util/reflection/IClassLoader.java @@ -5,8 +5,6 @@ import java.util.ServiceLoader; -import org.jspecify.annotations.NullMarked; - /** * Instances of this class allow to access {@link Class}es at runtime in a special application type. *

@@ -16,7 +14,6 @@ * @author Martin Hentschel * @see ClassLoaderUtil */ -@NullMarked public interface IClassLoader { /** * Returns the {@link Class} for the given class name similar to {@link Class#forName(String)}. diff --git a/key.util/src/main/java/org/key_project/util/reflection/JavaApplicationClassLoader.java b/key.util/src/main/java/org/key_project/util/reflection/JavaApplicationClassLoader.java index 39fa57f6204..e088119d9e2 100644 --- a/key.util/src/main/java/org/key_project/util/reflection/JavaApplicationClassLoader.java +++ b/key.util/src/main/java/org/key_project/util/reflection/JavaApplicationClassLoader.java @@ -5,8 +5,6 @@ import java.util.ServiceLoader; -import org.jspecify.annotations.NullMarked; - /** * An {@link IClassLoader} implementation for Java Applications. *

@@ -15,7 +13,6 @@ * * @author Martin Hentschel */ -@NullMarked public class JavaApplicationClassLoader implements IClassLoader { /** * {@inheritDoc} diff --git a/key.util/src/main/java/org/key_project/util/reflection/package-info.java b/key.util/src/main/java/org/key_project/util/reflection/package-info.java new file mode 100644 index 00000000000..5c2695077d4 --- /dev/null +++ b/key.util/src/main/java/org/key_project/util/reflection/package-info.java @@ -0,0 +1,4 @@ +@NullMarked +package org.key_project.util.reflection; + +import org.jspecify.annotations.NullMarked; From 4d01325797382f61def6c6f2240c56d154f81497 Mon Sep 17 00:00:00 2001 From: Florian Lanzinger Date: Wed, 8 Nov 2023 20:36:23 +0100 Subject: [PATCH 27/37] Fix typos in Readme --- key.util/Readme.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/key.util/Readme.md b/key.util/Readme.md index 284b87182ae..0da4579914a 100644 --- a/key.util/Readme.md +++ b/key.util/Readme.md @@ -33,7 +33,7 @@ The Checker Framework also checks for initialization: If a constructor does not initialize every `@NonNull` field with a non-null value, an error to that effect is reported at compile time. If a constructor tries to call a non-helper method, an error is also reported, as that method may rely on all `@NonNull` -being initialized. +fields being initialized. You can mark a method as helper by specifying `@UnderInitialization(InitClass.class) ReceiverClass this` as the first parameter, where `ReceiverClass` is the name of the current class, and @@ -69,7 +69,7 @@ class B extends A { fieldB = new Object(); // Allowed now because fieldB was just initialized - helper1(); + helperB(); // Not allowed because B is not final; thus there may be a subclass // for which this has not yet been initialized. From 87bb9792d6f82cb2c4f5130fb1048c93e7884b43 Mon Sep 17 00:00:00 2001 From: Florian Lanzinger Date: Wed, 22 Nov 2023 19:45:55 +0100 Subject: [PATCH 28/37] Spotless --- .../ilkd/key/java/ParseExceptionInFile.java | 1 - .../ilkd/key/java/PosConvertException.java | 2 - .../de/uka/ilkd/key/java/Recoder2KeY.java | 1 - .../key/java/recoderext/JMLTransformer.java | 1 - .../java/de/uka/ilkd/key/ldt/CharListLDT.java | 2 - .../java/de/uka/ilkd/key/ldt/IntegerLDT.java | 2 - .../main/java/de/uka/ilkd/key/ldt/LDT.java | 1 - .../java/de/uka/ilkd/key/ldt/LocSetLDT.java | 2 - .../main/java/de/uka/ilkd/key/ldt/SeqLDT.java | 2 - .../java/de/uka/ilkd/key/logic/Choice.java | 1 + .../de/uka/ilkd/key/logic/ChoiceExpr.java | 1 + .../java/de/uka/ilkd/key/logic/Namespace.java | 1 - .../main/java/de/uka/ilkd/key/logic/Term.java | 2 - .../de/uka/ilkd/key/logic/TermFactory.java | 1 - .../java/de/uka/ilkd/key/logic/TermImpl.java | 1 - .../ilkd/key/logic/label/OriginTermLabel.java | 1 - .../uka/ilkd/key/logic/sort/AbstractSort.java | 2 - .../java/de/uka/ilkd/key/logic/sort/Sort.java | 2 - .../ilkd/key/macros/scripts/EngineState.java | 1 - .../key/macros/scripts/ScriptException.java | 2 - .../key/macros/scripts/ScriptLineParser.java | 1 - .../java/de/uka/ilkd/key/nparser/KeyIO.java | 4 +- .../uka/ilkd/key/nparser/ParsingFacade.java | 5 +- .../uka/ilkd/key/nparser/ProofReplayer.java | 2 +- .../key/nparser/builder/AbstractBuilder.java | 4 +- .../key/nparser/builder/BuilderHelpers.java | 2 - .../key/nparser/builder/ChoiceFinder.java | 1 - .../builder/ContractsAndInvariantsFinder.java | 1 - .../nparser/builder/ExpressionBuilder.java | 1 - .../builder/FindProblemInformation.java | 1 - .../key/nparser/builder/ProblemFinder.java | 2 - .../key/nparser/builder/TacletPBuilder.java | 4 +- .../nparser/varexp/TacletBuilderCommand.java | 1 - .../varexp/TacletBuilderManipulators.java | 3 +- .../java/de/uka/ilkd/key/parser/Location.java | 1 - .../uka/ilkd/key/parser/ParserException.java | 2 - .../main/java/de/uka/ilkd/key/proof/Goal.java | 3 +- .../main/java/de/uka/ilkd/key/proof/Node.java | 5 +- .../java/de/uka/ilkd/key/proof/Proof.java | 46 +++++++++---------- .../de/uka/ilkd/key/proof/RuleAppIndex.java | 4 +- .../SVInstantiationExceptionWithPosition.java | 3 +- .../de/uka/ilkd/key/proof/TacletAppIndex.java | 4 +- .../de/uka/ilkd/key/proof/TacletIndex.java | 3 +- .../uka/ilkd/key/proof/init/InitConfig.java | 3 +- .../key/proof/init/KeYUserProblemFile.java | 4 +- .../de/uka/ilkd/key/proof/io/EnvInput.java | 5 +- .../uka/ilkd/key/proof/io/FileRuleSource.java | 2 +- .../proof/io/IntermediateProofReplayer.java | 1 - .../de/uka/ilkd/key/proof/io/KeYFile.java | 4 +- .../ilkd/key/proof/mgt/ProofEnvironment.java | 1 - .../uka/ilkd/key/proof/mgt/package-info.java | 2 +- .../ilkd/key/rule/AbstractBuiltInRuleApp.java | 3 +- .../key/rule/BlockContractExternalRule.java | 3 +- .../key/rule/BlockContractInternalRule.java | 3 +- .../de/uka/ilkd/key/rule/BuiltInRule.java | 4 +- .../de/uka/ilkd/key/rule/JmlAssertRule.java | 3 +- .../uka/ilkd/key/rule/LoopApplyHeadRule.java | 4 +- .../key/rule/LoopContractExternalRule.java | 3 +- .../key/rule/LoopContractInternalRule.java | 3 +- .../ilkd/key/rule/LoopScopeInvariantRule.java | 3 +- .../uka/ilkd/key/rule/OneStepSimplifier.java | 3 +- .../de/uka/ilkd/key/rule/QueryExpand.java | 2 +- .../main/java/de/uka/ilkd/key/rule/Rule.java | 4 +- .../java/de/uka/ilkd/key/rule/RuleApp.java | 2 - .../java/de/uka/ilkd/key/rule/RuleKey.java | 2 - .../java/de/uka/ilkd/key/rule/Taclet.java | 5 +- .../java/de/uka/ilkd/key/rule/TacletApp.java | 1 - .../key/rule/UseDependencyContractRule.java | 3 +- .../key/rule/UseOperationContractRule.java | 3 +- .../uka/ilkd/key/rule/WhileInvariantRule.java | 3 +- .../ilkd/key/rule/merge/CloseAfterMerge.java | 3 +- .../de/uka/ilkd/key/rule/merge/MergeRule.java | 3 +- .../ilkd/key/settings/SettingsConverter.java | 3 +- .../java/de/uka/ilkd/key/smt/RuleAppSMT.java | 7 ++- .../ilkd/key/smt/SMTSolverImplementation.java | 2 +- .../uka/ilkd/key/smt/SmtLib2Translator.java | 3 +- .../communication/AbstractSolverSocket.java | 3 +- .../key/smt/communication/CVC4Socket.java | 3 +- .../key/smt/communication/CVC5Socket.java | 3 +- .../ExternalProcessLauncher.java | 1 + .../key/smt/communication/LegacyPipe.java | 5 +- .../uka/ilkd/key/smt/communication/Pipe.java | 1 + .../key/smt/communication/SimplePipe.java | 2 +- .../ilkd/key/smt/communication/TeeReader.java | 1 + .../ilkd/key/smt/communication/TeeWriter.java | 1 + .../key/smt/communication/Z3CESocket.java | 3 +- .../ilkd/key/smt/communication/Z3Socket.java | 3 +- .../ilkd/key/smt/newsmt2/MasterHandler.java | 1 - .../smt/newsmt2/ModularSMTLib2Translator.java | 2 +- .../key/smt/newsmt2/SMTHandlerServices.java | 2 +- .../ilkd/key/smt/solvertypes/SolverType.java | 6 +-- .../solvertypes/SolverTypeImplementation.java | 4 +- .../ilkd/key/smt/solvertypes/SolverTypes.java | 1 + .../ilkd/key/speclang/PositionedString.java | 3 +- .../key/speclang/SpecificationElement.java | 3 +- .../uka/ilkd/key/speclang/jml/JMLUtils.java | 1 + .../pretranslation/TextualJMLConstruct.java | 2 +- .../jml/pretranslation/TextualJMLDepends.java | 3 +- .../pretranslation/TextualJMLLoopSpec.java | 3 +- .../TextualJMLMergePointDecl.java | 10 ++-- .../pretranslation/TextualJMLSpecCase.java | 4 +- .../key/speclang/jml/translation/Context.java | 5 +- .../jml/translation/JMLSpecFactory.java | 4 +- .../key/speclang/njml/ContractClauses.java | 3 +- .../ilkd/key/speclang/njml/DoubleHandler.java | 3 +- .../ilkd/key/speclang/njml/FloatHandler.java | 3 +- .../key/speclang/njml/IntegerHandler.java | 3 +- .../uka/ilkd/key/speclang/njml/JmlCheck.java | 2 +- .../uka/ilkd/key/speclang/njml/JmlChecks.java | 2 +- .../uka/ilkd/key/speclang/njml/JmlFacade.java | 2 +- .../de/uka/ilkd/key/speclang/njml/JmlIO.java | 4 +- .../key/speclang/njml/JmlMarkerDecision.java | 1 + .../key/speclang/njml/JmlTermFactory.java | 4 +- .../ilkd/key/speclang/njml/LDTHandler.java | 3 +- .../njml/LabeledParserRuleContext.java | 4 +- .../njml/OverloadedOperatorHandler.java | 3 +- .../uka/ilkd/key/speclang/njml/PreParser.java | 2 +- .../key/speclang/njml/TextualTranslator.java | 2 - .../ilkd/key/speclang/njml/Translator.java | 4 +- .../translation/SLExceptionFactory.java | 2 +- .../speclang/translation/SLExpression.java | 2 - .../translation/SLTranslationException.java | 3 +- .../ilkd/key/strategy/NumberRuleAppCost.java | 2 - .../strategy/QueueRuleApplicationManager.java | 3 +- .../feature/AppliedRuleAppsNameCache.java | 3 +- .../lemma/TacletProofObligationInput.java | 2 +- .../lemma/TacletSoundnessPOLoader.java | 3 +- .../de/uka/ilkd/key/util/ExceptionTools.java | 5 +- .../de/uka/ilkd/key/util/KeYTypeUtil.java | 3 +- .../java/de/uka/ilkd/key/util/MiscTools.java | 2 +- .../ilkd/key/util/RecognitionException.java | 2 +- .../key/util/mergerule/MergeRuleUtils.java | 2 +- .../de/uka/ilkd/key/util/package-info.java | 2 +- .../key/util/parsing/BuildingException.java | 2 +- .../ilkd/key/util/parsing/BuildingIssue.java | 2 - .../ilkd/key/util/parsing/HasLocation.java | 1 - .../key/util/parsing/LocatableException.java | 3 +- .../key/util/parsing/SyntaxErrorReporter.java | 2 +- .../de/uka/ilkd/key/util/pp/Layouter.java | 1 + .../ilkd/key/nparser/TestTacletEquality.java | 2 +- .../ilkd/key/parser/TestTermParserHeap.java | 2 +- .../ilkd/key/rule/merge/MergeRuleTests.java | 2 +- .../key/smt/newsmt2/MasterHandlerTest.java | 2 +- .../java/org/key_project/util/ExtList.java | 1 + .../java/org/key_project/util/Strings.java | 3 +- .../util/collection/IdentityHashSet.java | 8 ++-- .../testsuite/basic/BasicTestsSuite.java | 2 +- 147 files changed, 216 insertions(+), 210 deletions(-) diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/ParseExceptionInFile.java b/key.core/src/main/java/de/uka/ilkd/key/java/ParseExceptionInFile.java index ae367b46302..94b3c1c5709 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/ParseExceptionInFile.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/ParseExceptionInFile.java @@ -4,7 +4,6 @@ package de.uka.ilkd.key.java; import java.net.MalformedURLException; -import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.parser.Location; import de.uka.ilkd.key.util.ExceptionTools; diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/PosConvertException.java b/key.core/src/main/java/de/uka/ilkd/key/java/PosConvertException.java index c6d6d91b0ae..7c91a7785e8 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/PosConvertException.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/PosConvertException.java @@ -6,8 +6,6 @@ import java.net.MalformedURLException; -import org.jspecify.annotations.Nullable; - import de.uka.ilkd.key.parser.Location; import de.uka.ilkd.key.util.parsing.HasLocation; diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/Recoder2KeY.java b/key.core/src/main/java/de/uka/ilkd/key/java/Recoder2KeY.java index 39fead82182..9e5fa89fe18 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/Recoder2KeY.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/Recoder2KeY.java @@ -8,7 +8,6 @@ import java.nio.charset.StandardCharsets; import java.nio.file.Paths; import java.util.*; -import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.java.abstraction.KeYJavaType; import de.uka.ilkd.key.java.abstraction.NullType; diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/recoderext/JMLTransformer.java b/key.core/src/main/java/de/uka/ilkd/key/java/recoderext/JMLTransformer.java index d4798b0bf31..f36df966a19 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/recoderext/JMLTransformer.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/recoderext/JMLTransformer.java @@ -5,7 +5,6 @@ import java.net.URI; import java.util.*; -import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.parser.Location; import de.uka.ilkd.key.settings.ProofIndependentSettings; diff --git a/key.core/src/main/java/de/uka/ilkd/key/ldt/CharListLDT.java b/key.core/src/main/java/de/uka/ilkd/key/ldt/CharListLDT.java index 5a0c6f5ec79..7540c0ce69e 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/ldt/CharListLDT.java +++ b/key.core/src/main/java/de/uka/ilkd/key/ldt/CharListLDT.java @@ -3,8 +3,6 @@ * SPDX-License-Identifier: GPL-2.0-only */ package de.uka.ilkd.key.ldt; -import org.jspecify.annotations.Nullable; - import de.uka.ilkd.key.java.ConvertException; import de.uka.ilkd.key.java.Expression; import de.uka.ilkd.key.java.Services; diff --git a/key.core/src/main/java/de/uka/ilkd/key/ldt/IntegerLDT.java b/key.core/src/main/java/de/uka/ilkd/key/ldt/IntegerLDT.java index 2c045dfb0be..70469cb41d3 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/ldt/IntegerLDT.java +++ b/key.core/src/main/java/de/uka/ilkd/key/ldt/IntegerLDT.java @@ -3,8 +3,6 @@ * SPDX-License-Identifier: GPL-2.0-only */ package de.uka.ilkd.key.ldt; -import org.jspecify.annotations.Nullable; - import de.uka.ilkd.key.java.Expression; import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.java.abstraction.PrimitiveType; diff --git a/key.core/src/main/java/de/uka/ilkd/key/ldt/LDT.java b/key.core/src/main/java/de/uka/ilkd/key/ldt/LDT.java index 1a1eb8b0e76..e08ed787951 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/ldt/LDT.java +++ b/key.core/src/main/java/de/uka/ilkd/key/ldt/LDT.java @@ -5,7 +5,6 @@ import java.util.Map; import java.util.TreeMap; -import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.java.Expression; import de.uka.ilkd.key.java.Services; diff --git a/key.core/src/main/java/de/uka/ilkd/key/ldt/LocSetLDT.java b/key.core/src/main/java/de/uka/ilkd/key/ldt/LocSetLDT.java index 881ded67cc5..d4b816deb7f 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/ldt/LocSetLDT.java +++ b/key.core/src/main/java/de/uka/ilkd/key/ldt/LocSetLDT.java @@ -3,8 +3,6 @@ * SPDX-License-Identifier: GPL-2.0-only */ package de.uka.ilkd.key.ldt; -import org.jspecify.annotations.Nullable; - import de.uka.ilkd.key.java.Expression; import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.java.abstraction.Type; diff --git a/key.core/src/main/java/de/uka/ilkd/key/ldt/SeqLDT.java b/key.core/src/main/java/de/uka/ilkd/key/ldt/SeqLDT.java index acf2775492e..2370f9c015f 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/ldt/SeqLDT.java +++ b/key.core/src/main/java/de/uka/ilkd/key/ldt/SeqLDT.java @@ -3,8 +3,6 @@ * SPDX-License-Identifier: GPL-2.0-only */ package de.uka.ilkd.key.ldt; -import org.jspecify.annotations.Nullable; - import de.uka.ilkd.key.java.Expression; import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.java.abstraction.Type; diff --git a/key.core/src/main/java/de/uka/ilkd/key/logic/Choice.java b/key.core/src/main/java/de/uka/ilkd/key/logic/Choice.java index dd5aae92b7d..2de950ff418 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/logic/Choice.java +++ b/key.core/src/main/java/de/uka/ilkd/key/logic/Choice.java @@ -5,6 +5,7 @@ import java.util.List; import java.util.Objects; + import org.jspecify.annotations.NonNull; /** diff --git a/key.core/src/main/java/de/uka/ilkd/key/logic/ChoiceExpr.java b/key.core/src/main/java/de/uka/ilkd/key/logic/ChoiceExpr.java index f97eb88b57f..c2dbe6b6cfd 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/logic/ChoiceExpr.java +++ b/key.core/src/main/java/de/uka/ilkd/key/logic/ChoiceExpr.java @@ -5,6 +5,7 @@ import java.util.Objects; import java.util.Set; + import org.jspecify.annotations.NonNull; /** diff --git a/key.core/src/main/java/de/uka/ilkd/key/logic/Namespace.java b/key.core/src/main/java/de/uka/ilkd/key/logic/Namespace.java index 2d5e913349f..103e5ab4d09 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/logic/Namespace.java +++ b/key.core/src/main/java/de/uka/ilkd/key/logic/Namespace.java @@ -8,7 +8,6 @@ import java.util.Collections; import java.util.LinkedHashMap; import java.util.Map; -import org.jspecify.annotations.Nullable; import org.key_project.util.collection.ImmutableSet; diff --git a/key.core/src/main/java/de/uka/ilkd/key/logic/Term.java b/key.core/src/main/java/de/uka/ilkd/key/logic/Term.java index e498ae7527b..35ab6425c61 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/logic/Term.java +++ b/key.core/src/main/java/de/uka/ilkd/key/logic/Term.java @@ -3,8 +3,6 @@ * SPDX-License-Identifier: GPL-2.0-only */ package de.uka.ilkd.key.logic; -import org.jspecify.annotations.Nullable; - import de.uka.ilkd.key.logic.label.TermLabel; import de.uka.ilkd.key.logic.op.Operator; import de.uka.ilkd.key.logic.op.QuantifiableVariable; diff --git a/key.core/src/main/java/de/uka/ilkd/key/logic/TermFactory.java b/key.core/src/main/java/de/uka/ilkd/key/logic/TermFactory.java index 6534a0e419b..b4351b8d203 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/logic/TermFactory.java +++ b/key.core/src/main/java/de/uka/ilkd/key/logic/TermFactory.java @@ -6,7 +6,6 @@ import java.util.List; import java.util.Map; import java.util.Optional; -import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.logic.label.TermLabel; import de.uka.ilkd.key.logic.op.Operator; diff --git a/key.core/src/main/java/de/uka/ilkd/key/logic/TermImpl.java b/key.core/src/main/java/de/uka/ilkd/key/logic/TermImpl.java index dd8c5d41d37..66b8d9de5e3 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/logic/TermImpl.java +++ b/key.core/src/main/java/de/uka/ilkd/key/logic/TermImpl.java @@ -5,7 +5,6 @@ import java.util.Objects; import java.util.concurrent.atomic.AtomicInteger; -import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.java.NameAbstractionTable; import de.uka.ilkd.key.java.PositionInfo; diff --git a/key.core/src/main/java/de/uka/ilkd/key/logic/label/OriginTermLabel.java b/key.core/src/main/java/de/uka/ilkd/key/logic/label/OriginTermLabel.java index f416ab20315..5adc7067338 100755 --- a/key.core/src/main/java/de/uka/ilkd/key/logic/label/OriginTermLabel.java +++ b/key.core/src/main/java/de/uka/ilkd/key/logic/label/OriginTermLabel.java @@ -5,7 +5,6 @@ import java.net.URI; import java.util.*; -import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.java.JavaInfo; import de.uka.ilkd.key.java.Services; diff --git a/key.core/src/main/java/de/uka/ilkd/key/logic/sort/AbstractSort.java b/key.core/src/main/java/de/uka/ilkd/key/logic/sort/AbstractSort.java index d4eb2246ce6..f47c61cef95 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/logic/sort/AbstractSort.java +++ b/key.core/src/main/java/de/uka/ilkd/key/logic/sort/AbstractSort.java @@ -3,8 +3,6 @@ * SPDX-License-Identifier: GPL-2.0-only */ package de.uka.ilkd.key.logic.sort; -import org.jspecify.annotations.Nullable; - import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.logic.Name; import de.uka.ilkd.key.logic.TermServices; diff --git a/key.core/src/main/java/de/uka/ilkd/key/logic/sort/Sort.java b/key.core/src/main/java/de/uka/ilkd/key/logic/sort/Sort.java index 638a55d5a47..1b0cd66440a 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/logic/sort/Sort.java +++ b/key.core/src/main/java/de/uka/ilkd/key/logic/sort/Sort.java @@ -3,8 +3,6 @@ * SPDX-License-Identifier: GPL-2.0-only */ package de.uka.ilkd.key.logic.sort; -import org.jspecify.annotations.Nullable; - import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.logic.Name; import de.uka.ilkd.key.logic.Named; diff --git a/key.core/src/main/java/de/uka/ilkd/key/macros/scripts/EngineState.java b/key.core/src/main/java/de/uka/ilkd/key/macros/scripts/EngineState.java index 9b4cba80f75..af899c41807 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/macros/scripts/EngineState.java +++ b/key.core/src/main/java/de/uka/ilkd/key/macros/scripts/EngineState.java @@ -9,7 +9,6 @@ import java.util.Objects; import java.util.Optional; import java.util.function.Consumer; -import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.logic.Sequent; diff --git a/key.core/src/main/java/de/uka/ilkd/key/macros/scripts/ScriptException.java b/key.core/src/main/java/de/uka/ilkd/key/macros/scripts/ScriptException.java index a8b634733c2..e941773551f 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/macros/scripts/ScriptException.java +++ b/key.core/src/main/java/de/uka/ilkd/key/macros/scripts/ScriptException.java @@ -3,8 +3,6 @@ * SPDX-License-Identifier: GPL-2.0-only */ package de.uka.ilkd.key.macros.scripts; -import org.jspecify.annotations.Nullable; - import de.uka.ilkd.key.parser.Location; import de.uka.ilkd.key.util.parsing.HasLocation; diff --git a/key.core/src/main/java/de/uka/ilkd/key/macros/scripts/ScriptLineParser.java b/key.core/src/main/java/de/uka/ilkd/key/macros/scripts/ScriptLineParser.java index 87674557b2f..c6b5e3db7b0 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/macros/scripts/ScriptLineParser.java +++ b/key.core/src/main/java/de/uka/ilkd/key/macros/scripts/ScriptLineParser.java @@ -8,7 +8,6 @@ import java.net.URI; import java.util.HashMap; import java.util.Map; -import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.java.Position; import de.uka.ilkd.key.parser.Location; diff --git a/key.core/src/main/java/de/uka/ilkd/key/nparser/KeyIO.java b/key.core/src/main/java/de/uka/ilkd/key/nparser/KeyIO.java index cb21f84108b..f223436ced1 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/nparser/KeyIO.java +++ b/key.core/src/main/java/de/uka/ilkd/key/nparser/KeyIO.java @@ -10,8 +10,6 @@ import java.util.ArrayList; import java.util.LinkedList; import java.util.List; -import org.jspecify.annotations.NonNull; -import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.logic.Namespace; @@ -29,6 +27,8 @@ import org.antlr.v4.runtime.CharStream; import org.antlr.v4.runtime.CharStreams; +import org.jspecify.annotations.NonNull; +import org.jspecify.annotations.Nullable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/key.core/src/main/java/de/uka/ilkd/key/nparser/ParsingFacade.java b/key.core/src/main/java/de/uka/ilkd/key/nparser/ParsingFacade.java index 2490ed8d964..4ca0b331c6c 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/nparser/ParsingFacade.java +++ b/key.core/src/main/java/de/uka/ilkd/key/nparser/ParsingFacade.java @@ -23,12 +23,11 @@ import org.antlr.v4.runtime.atn.PredictionMode; import org.antlr.v4.runtime.misc.ParseCancellationException; import org.antlr.v4.runtime.tree.TerminalNode; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import org.jspecify.annotations.NonNull; import org.jspecify.annotations.NullMarked; import org.jspecify.annotations.Nullable; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * This facade provides low-level access to the ANTLR4 Parser and Lexer. diff --git a/key.core/src/main/java/de/uka/ilkd/key/nparser/ProofReplayer.java b/key.core/src/main/java/de/uka/ilkd/key/nparser/ProofReplayer.java index 9021a4ba371..d8edeaaf10f 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/nparser/ProofReplayer.java +++ b/key.core/src/main/java/de/uka/ilkd/key/nparser/ProofReplayer.java @@ -5,7 +5,6 @@ import java.net.URI; import java.util.*; -import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.java.Position; import de.uka.ilkd.key.parser.Location; @@ -15,6 +14,7 @@ import org.antlr.v4.runtime.CharStream; import org.antlr.v4.runtime.CommonTokenStream; import org.antlr.v4.runtime.Token; +import org.jspecify.annotations.NonNull; /** * A short little hack, but completely working and fast, for replaying proofs inside KeY files. diff --git a/key.core/src/main/java/de/uka/ilkd/key/nparser/builder/AbstractBuilder.java b/key.core/src/main/java/de/uka/ilkd/key/nparser/builder/AbstractBuilder.java index b3be7ed8a35..5acde7d45f7 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/nparser/builder/AbstractBuilder.java +++ b/key.core/src/main/java/de/uka/ilkd/key/nparser/builder/AbstractBuilder.java @@ -5,8 +5,6 @@ import java.util.*; import java.util.stream.Collectors; -import org.jspecify.annotations.NonNull; -import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.nparser.KeYParserBaseVisitor; import de.uka.ilkd.key.util.parsing.BuildingException; @@ -14,6 +12,8 @@ import org.antlr.v4.runtime.ParserRuleContext; import org.antlr.v4.runtime.RuleContext; +import org.jspecify.annotations.NonNull; +import org.jspecify.annotations.Nullable; /** * This class brings some nice features to the visitors of key's ast. diff --git a/key.core/src/main/java/de/uka/ilkd/key/nparser/builder/BuilderHelpers.java b/key.core/src/main/java/de/uka/ilkd/key/nparser/builder/BuilderHelpers.java index 26ed0be2cc3..ade97ba37d1 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/nparser/builder/BuilderHelpers.java +++ b/key.core/src/main/java/de/uka/ilkd/key/nparser/builder/BuilderHelpers.java @@ -3,8 +3,6 @@ * SPDX-License-Identifier: GPL-2.0-only */ package de.uka.ilkd.key.nparser.builder; -import org.jspecify.annotations.Nullable; - import org.antlr.v4.runtime.ParserRuleContext; import org.antlr.v4.runtime.Token; import org.jspecify.annotations.Nullable; diff --git a/key.core/src/main/java/de/uka/ilkd/key/nparser/builder/ChoiceFinder.java b/key.core/src/main/java/de/uka/ilkd/key/nparser/builder/ChoiceFinder.java index c2d200883e0..4061bcd293d 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/nparser/builder/ChoiceFinder.java +++ b/key.core/src/main/java/de/uka/ilkd/key/nparser/builder/ChoiceFinder.java @@ -4,7 +4,6 @@ package de.uka.ilkd.key.nparser.builder; import java.util.*; -import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.logic.Choice; import de.uka.ilkd.key.logic.Name; diff --git a/key.core/src/main/java/de/uka/ilkd/key/nparser/builder/ContractsAndInvariantsFinder.java b/key.core/src/main/java/de/uka/ilkd/key/nparser/builder/ContractsAndInvariantsFinder.java index 7a5cae64302..7b2e9471a8e 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/nparser/builder/ContractsAndInvariantsFinder.java +++ b/key.core/src/main/java/de/uka/ilkd/key/nparser/builder/ContractsAndInvariantsFinder.java @@ -5,7 +5,6 @@ import java.util.ArrayList; import java.util.List; -import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.logic.Namespace; diff --git a/key.core/src/main/java/de/uka/ilkd/key/nparser/builder/ExpressionBuilder.java b/key.core/src/main/java/de/uka/ilkd/key/nparser/builder/ExpressionBuilder.java index 08ec0782674..1cc53a2eda6 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/nparser/builder/ExpressionBuilder.java +++ b/key.core/src/main/java/de/uka/ilkd/key/nparser/builder/ExpressionBuilder.java @@ -10,7 +10,6 @@ import java.util.Objects; import java.util.function.Supplier; import java.util.stream.Collectors; -import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.java.*; import de.uka.ilkd.key.java.abstraction.KeYJavaType; diff --git a/key.core/src/main/java/de/uka/ilkd/key/nparser/builder/FindProblemInformation.java b/key.core/src/main/java/de/uka/ilkd/key/nparser/builder/FindProblemInformation.java index 51610b21139..67b92a0bca3 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/nparser/builder/FindProblemInformation.java +++ b/key.core/src/main/java/de/uka/ilkd/key/nparser/builder/FindProblemInformation.java @@ -5,7 +5,6 @@ import java.util.List; import java.util.Objects; -import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.nparser.KeYParser; import de.uka.ilkd.key.nparser.ParsingFacade; diff --git a/key.core/src/main/java/de/uka/ilkd/key/nparser/builder/ProblemFinder.java b/key.core/src/main/java/de/uka/ilkd/key/nparser/builder/ProblemFinder.java index e066e430836..cce301be71d 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/nparser/builder/ProblemFinder.java +++ b/key.core/src/main/java/de/uka/ilkd/key/nparser/builder/ProblemFinder.java @@ -3,8 +3,6 @@ * SPDX-License-Identifier: GPL-2.0-only */ package de.uka.ilkd.key.nparser.builder; -import org.jspecify.annotations.Nullable; - import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.java.abstraction.KeYJavaType; import de.uka.ilkd.key.logic.*; diff --git a/key.core/src/main/java/de/uka/ilkd/key/nparser/builder/TacletPBuilder.java b/key.core/src/main/java/de/uka/ilkd/key/nparser/builder/TacletPBuilder.java index bae04c555c5..bcba013b7c3 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/nparser/builder/TacletPBuilder.java +++ b/key.core/src/main/java/de/uka/ilkd/key/nparser/builder/TacletPBuilder.java @@ -5,8 +5,6 @@ import java.util.*; import java.util.stream.Collectors; -import org.jspecify.annotations.NonNull; -import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.java.abstraction.KeYJavaType; @@ -36,6 +34,8 @@ import antlr.RecognitionException; import org.antlr.v4.runtime.ParserRuleContext; import org.antlr.v4.runtime.Token; +import org.jspecify.annotations.NonNull; +import org.jspecify.annotations.Nullable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/key.core/src/main/java/de/uka/ilkd/key/nparser/varexp/TacletBuilderCommand.java b/key.core/src/main/java/de/uka/ilkd/key/nparser/varexp/TacletBuilderCommand.java index 3d0c815d9d2..a1b31cc69a7 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/nparser/varexp/TacletBuilderCommand.java +++ b/key.core/src/main/java/de/uka/ilkd/key/nparser/varexp/TacletBuilderCommand.java @@ -4,7 +4,6 @@ package de.uka.ilkd.key.nparser.varexp; import java.util.List; -import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.rule.tacletbuilder.TacletBuilder; diff --git a/key.core/src/main/java/de/uka/ilkd/key/nparser/varexp/TacletBuilderManipulators.java b/key.core/src/main/java/de/uka/ilkd/key/nparser/varexp/TacletBuilderManipulators.java index a2a129a7ea8..5aa5193b690 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/nparser/varexp/TacletBuilderManipulators.java +++ b/key.core/src/main/java/de/uka/ilkd/key/nparser/varexp/TacletBuilderManipulators.java @@ -8,7 +8,6 @@ import java.util.List; import java.util.ServiceLoader; import java.util.stream.Collectors; -import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.java.abstraction.KeYJavaType; import de.uka.ilkd.key.logic.Term; @@ -20,6 +19,8 @@ import de.uka.ilkd.key.rule.conditions.*; import de.uka.ilkd.key.rule.tacletbuilder.TacletBuilder; +import org.jspecify.annotations.NonNull; + import static de.uka.ilkd.key.nparser.varexp.ArgumentType.SORT; import static de.uka.ilkd.key.nparser.varexp.ArgumentType.TYPE_RESOLVER; import static de.uka.ilkd.key.rule.conditions.TypeComparisonCondition.Mode.*; diff --git a/key.core/src/main/java/de/uka/ilkd/key/parser/Location.java b/key.core/src/main/java/de/uka/ilkd/key/parser/Location.java index 4abff31d528..46b4b813bbf 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/parser/Location.java +++ b/key.core/src/main/java/de/uka/ilkd/key/parser/Location.java @@ -9,7 +9,6 @@ import java.util.Comparator; import java.util.Objects; import java.util.Optional; -import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.java.Position; import de.uka.ilkd.key.util.MiscTools; diff --git a/key.core/src/main/java/de/uka/ilkd/key/parser/ParserException.java b/key.core/src/main/java/de/uka/ilkd/key/parser/ParserException.java index 7053adf4c96..ec53ac9dcb7 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/parser/ParserException.java +++ b/key.core/src/main/java/de/uka/ilkd/key/parser/ParserException.java @@ -3,8 +3,6 @@ * SPDX-License-Identifier: GPL-2.0-only */ package de.uka.ilkd.key.parser; -import org.jspecify.annotations.Nullable; - import de.uka.ilkd.key.util.parsing.HasLocation; import org.jspecify.annotations.Nullable; diff --git a/key.core/src/main/java/de/uka/ilkd/key/proof/Goal.java b/key.core/src/main/java/de/uka/ilkd/key/proof/Goal.java index f2d3fdcfd08..b86a6a47719 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/proof/Goal.java +++ b/key.core/src/main/java/de/uka/ilkd/key/proof/Goal.java @@ -8,7 +8,6 @@ import java.util.LinkedList; import java.util.List; import java.util.concurrent.atomic.AtomicLong; -import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.logic.*; @@ -34,6 +33,8 @@ import org.key_project.util.collection.ImmutableList; import org.key_project.util.collection.ImmutableSLList; +import org.jspecify.annotations.NonNull; + /** * A proof is represented as a tree of nodes containing sequents. The initial proof consists of just * one node -- the root -- that has to be proved. Therefore it is divided up into several sub goals diff --git a/key.core/src/main/java/de/uka/ilkd/key/proof/Node.java b/key.core/src/main/java/de/uka/ilkd/key/proof/Node.java index 22211556e8a..533828bb803 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/proof/Node.java +++ b/key.core/src/main/java/de/uka/ilkd/key/proof/Node.java @@ -12,8 +12,6 @@ import java.util.LinkedList; import java.util.List; import java.util.ListIterator; -import org.jspecify.annotations.NonNull; -import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.logic.RenamingTable; import de.uka.ilkd.key.logic.Sequent; @@ -32,6 +30,9 @@ import org.key_project.util.collection.ImmutableSet; import org.key_project.util.lookup.Lookup; +import org.jspecify.annotations.NonNull; +import org.jspecify.annotations.Nullable; + public class Node implements Iterable { private static final String RULE_WITHOUT_NAME = "rule without name"; diff --git a/key.core/src/main/java/de/uka/ilkd/key/proof/Proof.java b/key.core/src/main/java/de/uka/ilkd/key/proof/Proof.java index f51d8f92963..0060cfb6dc6 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/proof/Proof.java +++ b/key.core/src/main/java/de/uka/ilkd/key/proof/Proof.java @@ -31,8 +31,8 @@ import org.key_project.util.lookup.Lookup; import org.jspecify.annotations.NonNull; -import org.jspecify.annotations.Nullable; import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; /** @@ -139,7 +139,7 @@ public class Proof implements Named { * list of rule app listeners */ private final List ruleAppListenerList = - Collections.synchronizedList(new ArrayList<>(10)); + Collections.synchronizedList(new ArrayList<>(10)); /** * Contains all registered {@link ProofDisposedListener}. */ @@ -176,7 +176,7 @@ private Proof(Name name, InitConfig initConfig) { final Services services = this.initConfig.getServices(); services.setProof(this); this.proofFile = - services.getJavaModel() != null ? services.getJavaModel().getInitialFile() : null; + services.getJavaModel() != null ? services.getJavaModel().getInitialFile() : null; settingsListener = config -> updateStrategyOnGoals(); @@ -192,17 +192,17 @@ private Proof(Name name, InitConfig initConfig) { */ private void initStrategy() { StrategyProperties activeStrategyProperties = - initConfig.getSettings().getStrategySettings().getActiveStrategyProperties(); + initConfig.getSettings().getStrategySettings().getActiveStrategyProperties(); final Profile profile = getServices().getProfile(); final Name strategy = initConfig.getSettings().getStrategySettings().getStrategy(); if (profile.supportsStrategyFactory(strategy)) { setActiveStrategy( - profile.getStrategyFactory(strategy).create(this, activeStrategyProperties)); + profile.getStrategyFactory(strategy).create(this, activeStrategyProperties)); } else { setActiveStrategy( - profile.getDefaultStrategyFactory().create(this, activeStrategyProperties)); + profile.getDefaultStrategyFactory().create(this, activeStrategyProperties)); } } @@ -215,7 +215,7 @@ public Proof(String name, InitConfig initConfig) { } private Proof(String name, Sequent problem, TacletIndex rules, BuiltInRuleIndex builtInRules, - InitConfig initConfig) { + InitConfig initConfig) { this(new Name(name), initConfig); final var rootNode = new Node(this, problem); @@ -239,15 +239,15 @@ public Proof(String name, Sequent problem, String header, InitConfig initConfig, public Proof(String name, Term problem, String header, InitConfig initConfig) { this(name, - Sequent.createSuccSequent( - Semisequent.EMPTY_SEMISEQUENT.insert(0, new SequentFormula(problem)).semisequent()), - initConfig.createTacletIndex(), initConfig.createBuiltInRuleIndex(), initConfig); + Sequent.createSuccSequent( + Semisequent.EMPTY_SEMISEQUENT.insert(0, new SequentFormula(problem)).semisequent()), + initConfig.createTacletIndex(), initConfig.createBuiltInRuleIndex(), initConfig); problemHeader = header; } public Proof(String name, Sequent sequent, String header, TacletIndex rules, - BuiltInRuleIndex builtInRules, InitConfig initConfig) { + BuiltInRuleIndex builtInRules, InitConfig initConfig) { this(name, sequent, rules, builtInRules, initConfig); problemHeader = header; } @@ -511,9 +511,9 @@ private ImmutableList filterEnabledGoals(ImmutableList goals) { /** * removes the given goal and adds the new goals in list * - * @param oldGoal the old goal that has to be removed from list + * @param oldGoal the old goal that has to be removed from list * @param newGoals the IList with the new goals that were result of a rule application on - * goal + * goal */ public void replace(Goal oldGoal, ImmutableList newGoals) { openGoals = openGoals.removeAll(oldGoal); @@ -959,7 +959,7 @@ public Goal getOpenGoal(Node node) { /** * @param node the Node which is checked for a corresponding closed goal * @return true if the goal that belongs to the given node is closed and false if not or if - * there is no such goal. + * there is no such goal. */ public boolean isClosedGoal(Node node) { return getClosedGoal(node) != null; @@ -970,7 +970,7 @@ public boolean isClosedGoal(Node node) { * * @param node the Node where a corresponding closed goal is searched * @return the closed goal that belongs to the given node or null if the node is an inner one or - * an open goal + * an open goal */ public Goal getClosedGoal(Node node) { for (final Goal result : closedGoals) { @@ -1006,7 +1006,7 @@ public ImmutableList getClosedSubtreeGoals(Node node) { * Returns a list of all goals from the provided list that are associated to goals below * node * - * @param node the root of the subtree + * @param node the root of the subtree * @param fromGoals the list of goals from which to select * @return the goals below node that are contained in fromGoals */ @@ -1213,7 +1213,7 @@ public InitConfig getInitConfig() { * Returns the {@link File} under which the {@link Proof} was saved the last time if available. * * @return The {@link File} under which the {@link Proof} was saved the last time or - * {@code null} if not available. + * {@code null} if not available. */ public File getProofFile() { return proofFile; @@ -1230,7 +1230,7 @@ public void setProofFile(File proofFile) { /** * @return the current profile's factory for the active strategy, or the default factory if - * there is no active strategy. + * there is no active strategy. * @see Profile#getStrategyFactory(Name) * @see #getActiveStrategy() */ @@ -1246,7 +1246,7 @@ public StrategyFactory getActiveStrategyFactory() { * Retrieves a user-defined data. * * @param service the class for which the data were registered - * @param any class + * @param any class * @return null or the previous data * @see #register(Object, Class) */ @@ -1264,9 +1264,9 @@ public T lookup(Class service) { /** * Register a user-defined data in this node info. * - * @param obj an object to be registered + * @param obj an object to be registered * @param service the key under it should be registered - * @param type of the object to register + * @param type of the object to register */ public void register(T obj, Class service) { getUserData().register(obj, service); @@ -1275,9 +1275,9 @@ public void register(T obj, Class service) { /** * Remove a previous registered user-defined data. * - * @param obj registered object + * @param obj registered object * @param service the key under which the data was registered - * @param type of the object to unregister + * @param type of the object to unregister */ public void deregister(T obj, Class service) { if (userData != null) { diff --git a/key.core/src/main/java/de/uka/ilkd/key/proof/RuleAppIndex.java b/key.core/src/main/java/de/uka/ilkd/key/proof/RuleAppIndex.java index c3f9c7d372c..65ba69b0c9d 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/proof/RuleAppIndex.java +++ b/key.core/src/main/java/de/uka/ilkd/key/proof/RuleAppIndex.java @@ -3,8 +3,6 @@ * SPDX-License-Identifier: GPL-2.0-only */ package de.uka.ilkd.key.proof; -import org.jspecify.annotations.Nullable; - import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.logic.PosInOccurrence; import de.uka.ilkd.key.logic.SequentChangeInfo; @@ -19,6 +17,8 @@ import org.key_project.util.collection.ImmutableList; import org.key_project.util.collection.ImmutableSLList; +import org.jspecify.annotations.Nullable; + /** * manages the possible application of rules (RuleApps) */ diff --git a/key.core/src/main/java/de/uka/ilkd/key/proof/SVInstantiationExceptionWithPosition.java b/key.core/src/main/java/de/uka/ilkd/key/proof/SVInstantiationExceptionWithPosition.java index 6aae06e5461..5999035fb84 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/proof/SVInstantiationExceptionWithPosition.java +++ b/key.core/src/main/java/de/uka/ilkd/key/proof/SVInstantiationExceptionWithPosition.java @@ -4,12 +4,13 @@ package de.uka.ilkd.key.proof; import java.net.MalformedURLException; -import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.java.Position; import de.uka.ilkd.key.parser.Location; import de.uka.ilkd.key.util.parsing.HasLocation; +import org.jspecify.annotations.Nullable; + /** * Represents an exception with position information. The row position is absolut this means, if in * a table it is the row of the table, but the column position is relative to the text and does not diff --git a/key.core/src/main/java/de/uka/ilkd/key/proof/TacletAppIndex.java b/key.core/src/main/java/de/uka/ilkd/key/proof/TacletAppIndex.java index 08151c0a739..c06aacaf18c 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/proof/TacletAppIndex.java +++ b/key.core/src/main/java/de/uka/ilkd/key/proof/TacletAppIndex.java @@ -6,8 +6,6 @@ import java.util.Iterator; import java.util.Map; import java.util.concurrent.atomic.AtomicLong; -import org.jspecify.annotations.NonNull; -import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.logic.PosInOccurrence; @@ -24,6 +22,8 @@ import org.key_project.util.collection.ImmutableList; import org.key_project.util.collection.ImmutableSLList; +import org.jspecify.annotations.NonNull; + /** * the class manages the available TacletApps. This index has to be used if one wants to ask for the diff --git a/key.core/src/main/java/de/uka/ilkd/key/proof/TacletIndex.java b/key.core/src/main/java/de/uka/ilkd/key/proof/TacletIndex.java index d7480b6ec57..92b4674c12f 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/proof/TacletIndex.java +++ b/key.core/src/main/java/de/uka/ilkd/key/proof/TacletIndex.java @@ -4,7 +4,6 @@ package de.uka.ilkd.key.proof; import java.util.*; -import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.java.*; import de.uka.ilkd.key.java.statement.*; @@ -24,6 +23,8 @@ import org.key_project.util.collection.ImmutableSLList; import org.key_project.util.collection.ImmutableSet; +import org.jspecify.annotations.Nullable; + /** * manages all applicable Taclets (more precisely: Taclets with instantiations but without position * information, the NoPosTacletApps) at one node. It is a persistent implementation. Taclets can be diff --git a/key.core/src/main/java/de/uka/ilkd/key/proof/init/InitConfig.java b/key.core/src/main/java/de/uka/ilkd/key/proof/init/InitConfig.java index 79436124294..53f6aecb3e1 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/proof/init/InitConfig.java +++ b/key.core/src/main/java/de/uka/ilkd/key/proof/init/InitConfig.java @@ -4,7 +4,6 @@ package de.uka.ilkd.key.proof.init; import java.util.*; -import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.logic.Choice; @@ -32,6 +31,8 @@ import org.key_project.util.collection.ImmutableSLList; import org.key_project.util.collection.ImmutableSet; +import org.jspecify.annotations.NonNull; + /** * an instance of this class describes the initial configuration of the prover. This includes sorts, * functions, heuristics, and variables namespaces, information on the underlying java model, and a diff --git a/key.core/src/main/java/de/uka/ilkd/key/proof/init/KeYUserProblemFile.java b/key.core/src/main/java/de/uka/ilkd/key/proof/init/KeYUserProblemFile.java index 9f9900d9765..be3786b1604 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/proof/init/KeYUserProblemFile.java +++ b/key.core/src/main/java/de/uka/ilkd/key/proof/init/KeYUserProblemFile.java @@ -6,7 +6,6 @@ import java.io.File; import java.io.IOException; import java.net.URISyntaxException; -import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.java.abstraction.KeYJavaType; import de.uka.ilkd.key.logic.Sequent; @@ -239,7 +238,8 @@ public Profile getProfile() { * is defined by the file. */ private Profile readProfileFromFile() { - @NonNull ProblemInformation pi = getProblemInformation(); + @NonNull + ProblemInformation pi = getProblemInformation(); String profileName = pi.getProfile(); if (profileName != null && !profileName.isEmpty()) { return ProofInitServiceUtil.getDefaultProfile(profileName); diff --git a/key.core/src/main/java/de/uka/ilkd/key/proof/io/EnvInput.java b/key.core/src/main/java/de/uka/ilkd/key/proof/io/EnvInput.java index 7dc4ba06292..70ea0c9ae09 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/proof/io/EnvInput.java +++ b/key.core/src/main/java/de/uka/ilkd/key/proof/io/EnvInput.java @@ -5,8 +5,6 @@ import java.io.File; import java.util.List; -import org.jspecify.annotations.NonNull; -import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.proof.init.Includes; import de.uka.ilkd.key.proof.init.InitConfig; @@ -16,6 +14,9 @@ import org.key_project.util.collection.ImmutableSet; +import org.jspecify.annotations.NonNull; +import org.jspecify.annotations.Nullable; + /** * Represents an entity read to produce an environment to read a proof obligation. Environment means diff --git a/key.core/src/main/java/de/uka/ilkd/key/proof/io/FileRuleSource.java b/key.core/src/main/java/de/uka/ilkd/key/proof/io/FileRuleSource.java index 1c910e4802d..6e2e79f14f7 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/proof/io/FileRuleSource.java +++ b/key.core/src/main/java/de/uka/ilkd/key/proof/io/FileRuleSource.java @@ -7,10 +7,10 @@ import java.net.MalformedURLException; import java.net.URL; import java.util.Objects; -import org.jspecify.annotations.NonNull; import org.antlr.v4.runtime.CharStream; import org.antlr.v4.runtime.CharStreams; +import org.jspecify.annotations.NonNull; public class FileRuleSource extends RuleSource { diff --git a/key.core/src/main/java/de/uka/ilkd/key/proof/io/IntermediateProofReplayer.java b/key.core/src/main/java/de/uka/ilkd/key/proof/io/IntermediateProofReplayer.java index 04f119d5903..fc3895e7b0c 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/proof/io/IntermediateProofReplayer.java +++ b/key.core/src/main/java/de/uka/ilkd/key/proof/io/IntermediateProofReplayer.java @@ -8,7 +8,6 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.stream.Collectors; -import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.axiom_abstraction.AbstractDomainElement; import de.uka.ilkd.key.axiom_abstraction.predicateabstraction.AbstractPredicateAbstractionLattice; diff --git a/key.core/src/main/java/de/uka/ilkd/key/proof/io/KeYFile.java b/key.core/src/main/java/de/uka/ilkd/key/proof/io/KeYFile.java index ec0a063600f..2540a706ea2 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/proof/io/KeYFile.java +++ b/key.core/src/main/java/de/uka/ilkd/key/proof/io/KeYFile.java @@ -14,8 +14,6 @@ import java.util.List; import java.util.Objects; import java.util.stream.Collectors; -import org.jspecify.annotations.NonNull; -import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.nparser.*; import de.uka.ilkd.key.nparser.builder.ContractsAndInvariantsFinder; @@ -38,6 +36,8 @@ import org.key_project.util.collection.ImmutableSet; import org.key_project.util.collection.Immutables; +import org.jspecify.annotations.NonNull; +import org.jspecify.annotations.Nullable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/key.core/src/main/java/de/uka/ilkd/key/proof/mgt/ProofEnvironment.java b/key.core/src/main/java/de/uka/ilkd/key/proof/mgt/ProofEnvironment.java index a49115d53f5..dc309abb9a5 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/proof/mgt/ProofEnvironment.java +++ b/key.core/src/main/java/de/uka/ilkd/key/proof/mgt/ProofEnvironment.java @@ -14,7 +14,6 @@ import de.uka.ilkd.key.proof.ProofAggregate; import de.uka.ilkd.key.proof.init.InitConfig; import de.uka.ilkd.key.proof.init.ProofOblInput; -import org.jspecify.annotations.NullMarked; /** * The unique environment a proof is performed in. The environment consists of a java model, diff --git a/key.core/src/main/java/de/uka/ilkd/key/proof/mgt/package-info.java b/key.core/src/main/java/de/uka/ilkd/key/proof/mgt/package-info.java index ecba0060431..4cb5be62e48 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/proof/mgt/package-info.java +++ b/key.core/src/main/java/de/uka/ilkd/key/proof/mgt/package-info.java @@ -6,4 +6,4 @@ @NullMarked package de.uka.ilkd.key.proof.mgt; -import org.jspecify.annotations.NullMarked; \ No newline at end of file +import org.jspecify.annotations.NullMarked; diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/AbstractBuiltInRuleApp.java b/key.core/src/main/java/de/uka/ilkd/key/rule/AbstractBuiltInRuleApp.java index 0eff264dacf..cc0f21552f8 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/AbstractBuiltInRuleApp.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/AbstractBuiltInRuleApp.java @@ -6,7 +6,6 @@ import java.util.List; import java.util.Objects; import java.util.concurrent.atomic.AtomicLong; -import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.logic.PosInOccurrence; @@ -16,6 +15,8 @@ import org.key_project.util.collection.ImmutableList; import org.key_project.util.collection.ImmutableSLList; +import org.jspecify.annotations.Nullable; + public abstract class AbstractBuiltInRuleApp implements IBuiltInRuleApp { public static final AtomicLong PERF_EXECUTE = new AtomicLong(); public static final AtomicLong PERF_SET_SEQUENT = new AtomicLong(); diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/BlockContractExternalRule.java b/key.core/src/main/java/de/uka/ilkd/key/rule/BlockContractExternalRule.java index ce402074da0..8726ad316fb 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/BlockContractExternalRule.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/BlockContractExternalRule.java @@ -5,7 +5,6 @@ import java.util.List; import java.util.Map; -import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.informationflow.proof.InfFlowCheckInfo; import de.uka.ilkd.key.java.Services; @@ -33,6 +32,8 @@ import org.key_project.util.collection.ImmutableSet; import org.key_project.util.java.ArrayUtil; +import org.jspecify.annotations.NonNull; + /** *

* Rule for the application of {@link BlockContract}s. diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/BlockContractInternalRule.java b/key.core/src/main/java/de/uka/ilkd/key/rule/BlockContractInternalRule.java index 3a762496595..76078d94679 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/BlockContractInternalRule.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/BlockContractInternalRule.java @@ -5,7 +5,6 @@ import java.util.List; import java.util.Map; -import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.informationflow.proof.InfFlowCheckInfo; import de.uka.ilkd.key.java.Services; @@ -34,6 +33,8 @@ import org.key_project.util.collection.ImmutableSet; import org.key_project.util.java.ArrayUtil; +import org.jspecify.annotations.NonNull; + /** *

* Rule for the application of {@link BlockContract}s. diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/BuiltInRule.java b/key.core/src/main/java/de/uka/ilkd/key/rule/BuiltInRule.java index a636d9bccb2..b4186dee23e 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/BuiltInRule.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/BuiltInRule.java @@ -3,12 +3,12 @@ * SPDX-License-Identifier: GPL-2.0-only */ package de.uka.ilkd.key.rule; -import org.jspecify.annotations.Nullable; - import de.uka.ilkd.key.logic.PosInOccurrence; import de.uka.ilkd.key.logic.TermServices; import de.uka.ilkd.key.proof.Goal; +import org.jspecify.annotations.Nullable; + /** * Buit-in rule interface. As applications of this rule kind may not be successful in each case one * has to ensure that the goal split is done only iff the application was successful. diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/JmlAssertRule.java b/key.core/src/main/java/de/uka/ilkd/key/rule/JmlAssertRule.java index 76fd90ac8b8..458aa8fb1ea 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/JmlAssertRule.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/JmlAssertRule.java @@ -4,7 +4,6 @@ package de.uka.ilkd.key.rule; import java.util.Optional; -import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.java.JavaTools; import de.uka.ilkd.key.java.Services; @@ -27,6 +26,8 @@ import org.key_project.util.collection.ImmutableList; +import org.jspecify.annotations.NonNull; + /** * A rule for JML assert/assume statements. * diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/LoopApplyHeadRule.java b/key.core/src/main/java/de/uka/ilkd/key/rule/LoopApplyHeadRule.java index 706ba5394f0..11f71f8bf45 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/LoopApplyHeadRule.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/LoopApplyHeadRule.java @@ -3,8 +3,6 @@ * SPDX-License-Identifier: GPL-2.0-only */ package de.uka.ilkd.key.rule; -import org.jspecify.annotations.NonNull; - import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.java.StatementBlock; import de.uka.ilkd.key.java.statement.While; @@ -27,6 +25,8 @@ import org.key_project.util.collection.ImmutableSLList; import org.key_project.util.collection.ImmutableSet; +import org.jspecify.annotations.NonNull; + /** *

* This rule transforms a block that starts with a for loop into one that starts with a while loop. diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/LoopContractExternalRule.java b/key.core/src/main/java/de/uka/ilkd/key/rule/LoopContractExternalRule.java index e6656f19dcb..0e3d3bcf4c1 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/LoopContractExternalRule.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/LoopContractExternalRule.java @@ -5,7 +5,6 @@ import java.util.List; import java.util.Map; -import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.informationflow.proof.InfFlowCheckInfo; import de.uka.ilkd.key.java.Services; @@ -34,6 +33,8 @@ import org.key_project.util.collection.ImmutableSet; import org.key_project.util.java.ArrayUtil; +import org.jspecify.annotations.NonNull; + /** *

* Rule for the application of {@link LoopContract}s. diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/LoopContractInternalRule.java b/key.core/src/main/java/de/uka/ilkd/key/rule/LoopContractInternalRule.java index ec7305d713b..cd1f8d7b01f 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/LoopContractInternalRule.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/LoopContractInternalRule.java @@ -5,7 +5,6 @@ import java.util.List; import java.util.Map; -import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.logic.Name; @@ -28,6 +27,8 @@ import org.key_project.util.collection.ImmutableSet; import org.key_project.util.java.ArrayUtil; +import org.jspecify.annotations.NonNull; + /** *

* Rule for the application of {@link LoopContract}s. diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/LoopScopeInvariantRule.java b/key.core/src/main/java/de/uka/ilkd/key/rule/LoopScopeInvariantRule.java index 53ffa834cd9..52fa14c216a 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/LoopScopeInvariantRule.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/LoopScopeInvariantRule.java @@ -5,7 +5,6 @@ import java.util.ArrayList; import java.util.Optional; -import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.informationflow.proof.InfFlowCheckInfo; import de.uka.ilkd.key.java.KeYJavaASTFactory; @@ -38,6 +37,8 @@ import org.key_project.util.collection.ImmutableArray; import org.key_project.util.collection.ImmutableList; +import org.jspecify.annotations.NonNull; + /** *

* Implementation of the "loop scope invariant" rule as proposed in the PhD thesis diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/OneStepSimplifier.java b/key.core/src/main/java/de/uka/ilkd/key/rule/OneStepSimplifier.java index ffb2a1eb2a3..4d14922e5d3 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/OneStepSimplifier.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/OneStepSimplifier.java @@ -9,7 +9,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.logic.Name; @@ -45,6 +44,8 @@ import org.key_project.util.collection.ImmutableSLList; import org.key_project.util.collection.Immutables; +import org.jspecify.annotations.NonNull; + public final class OneStepSimplifier implements BuiltInRule { /** diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/QueryExpand.java b/key.core/src/main/java/de/uka/ilkd/key/rule/QueryExpand.java index 81a291c19f6..ab1aff53743 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/QueryExpand.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/QueryExpand.java @@ -4,7 +4,6 @@ package de.uka.ilkd.key.rule; import java.util.*; -import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.java.*; import de.uka.ilkd.key.java.abstraction.KeYJavaType; @@ -27,6 +26,7 @@ import org.key_project.util.collection.ImmutableList; import org.key_project.util.collection.ImmutableSLList; +import org.jspecify.annotations.NonNull; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/Rule.java b/key.core/src/main/java/de/uka/ilkd/key/rule/Rule.java index 6daa195682b..a5db5fef4f3 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/Rule.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/Rule.java @@ -3,14 +3,14 @@ * SPDX-License-Identifier: GPL-2.0-only */ package de.uka.ilkd.key.rule; -import org.jspecify.annotations.NonNull; - import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.logic.Name; import de.uka.ilkd.key.proof.Goal; import org.key_project.util.collection.ImmutableList; +import org.jspecify.annotations.NonNull; + /** * This interface has to be implemented by all classes that want to act as a rule in the calculus. */ diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/RuleApp.java b/key.core/src/main/java/de/uka/ilkd/key/rule/RuleApp.java index 9e0d9491fd1..8c505c74360 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/RuleApp.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/RuleApp.java @@ -3,8 +3,6 @@ * SPDX-License-Identifier: GPL-2.0-only */ package de.uka.ilkd.key.rule; -import org.jspecify.annotations.Nullable; - import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.logic.PosInOccurrence; import de.uka.ilkd.key.proof.Goal; diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/RuleKey.java b/key.core/src/main/java/de/uka/ilkd/key/rule/RuleKey.java index 9412e2a1d66..7fe30775c97 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/RuleKey.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/RuleKey.java @@ -3,8 +3,6 @@ * SPDX-License-Identifier: GPL-2.0-only */ package de.uka.ilkd.key.rule; -import org.jspecify.annotations.NonNull; - import de.uka.ilkd.key.logic.ChoiceExpr; import de.uka.ilkd.key.logic.Name; diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/Taclet.java b/key.core/src/main/java/de/uka/ilkd/key/rule/Taclet.java index b1ab3924199..e2c385d8c63 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/Taclet.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/Taclet.java @@ -4,8 +4,6 @@ package de.uka.ilkd.key.rule; import java.util.*; -import org.jspecify.annotations.NonNull; -import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.logic.*; @@ -29,6 +27,9 @@ import org.key_project.util.collection.ImmutableMap; import org.key_project.util.collection.ImmutableSet; +import org.jspecify.annotations.NonNull; +import org.jspecify.annotations.Nullable; + import static org.key_project.util.Strings.formatAsList; diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/TacletApp.java b/key.core/src/main/java/de/uka/ilkd/key/rule/TacletApp.java index a102d481615..e6a9ea5fa92 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/TacletApp.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/TacletApp.java @@ -5,7 +5,6 @@ import java.util.*; import java.util.concurrent.atomic.AtomicLong; -import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.java.*; import de.uka.ilkd.key.java.abstraction.KeYJavaType; diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/UseDependencyContractRule.java b/key.core/src/main/java/de/uka/ilkd/key/rule/UseDependencyContractRule.java index 474af2a7010..3ab5a8dbe3a 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/UseDependencyContractRule.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/UseDependencyContractRule.java @@ -7,7 +7,6 @@ import java.util.LinkedList; import java.util.List; import java.util.Map; -import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.java.abstraction.KeYJavaType; @@ -30,6 +29,8 @@ import org.key_project.util.collection.ImmutableSLList; import org.key_project.util.collection.ImmutableSet; +import org.jspecify.annotations.NonNull; + public final class UseDependencyContractRule implements BuiltInRule { public static final UseDependencyContractRule INSTANCE = new UseDependencyContractRule(); diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/UseOperationContractRule.java b/key.core/src/main/java/de/uka/ilkd/key/rule/UseOperationContractRule.java index 58c57d84b5b..51fc999c89e 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/UseOperationContractRule.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/UseOperationContractRule.java @@ -6,7 +6,6 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; -import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.informationflow.proof.InfFlowCheckInfo; import de.uka.ilkd.key.informationflow.proof.InfFlowProof; @@ -76,6 +75,8 @@ import org.key_project.util.collection.ImmutableSLList; import org.key_project.util.collection.ImmutableSet; +import org.jspecify.annotations.NonNull; + /** * Implements the rule which inserts operation contracts for a method call. */ diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/WhileInvariantRule.java b/key.core/src/main/java/de/uka/ilkd/key/rule/WhileInvariantRule.java index 2c63167a28b..871ceaf6448 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/WhileInvariantRule.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/WhileInvariantRule.java @@ -7,7 +7,6 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; -import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.informationflow.po.IFProofObligationVars; import de.uka.ilkd.key.informationflow.po.snippet.InfFlowPOSnippetFactory; @@ -70,6 +69,8 @@ import org.key_project.util.collection.ImmutableSLList; import org.key_project.util.collection.ImmutableSet; +import org.jspecify.annotations.NonNull; + public final class WhileInvariantRule implements BuiltInRule { /** * The hint used to refactor the initial invariant. diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/merge/CloseAfterMerge.java b/key.core/src/main/java/de/uka/ilkd/key/rule/merge/CloseAfterMerge.java index d6cec95158f..b03fb381602 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/merge/CloseAfterMerge.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/merge/CloseAfterMerge.java @@ -9,7 +9,6 @@ import java.util.LinkedList; import java.util.Set; import java.util.stream.Collectors; -import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.logic.Name; @@ -39,6 +38,8 @@ import org.key_project.util.collection.ImmutableList; import org.key_project.util.collection.ImmutableSet; +import org.jspecify.annotations.NonNull; + import static de.uka.ilkd.key.util.mergerule.MergeRuleUtils.clearSemisequent; import static de.uka.ilkd.key.util.mergerule.MergeRuleUtils.getLocationVariables; import static de.uka.ilkd.key.util.mergerule.MergeRuleUtils.getUpdateLeftSideLocations; diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/merge/MergeRule.java b/key.core/src/main/java/de/uka/ilkd/key/rule/merge/MergeRule.java index 13044817a0d..a246ee47aea 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/merge/MergeRule.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/merge/MergeRule.java @@ -7,7 +7,6 @@ import java.util.HashMap; import java.util.Iterator; import java.util.LinkedHashSet; -import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.logic.JavaBlock; @@ -48,6 +47,8 @@ import org.key_project.util.collection.ImmutableSLList; import org.key_project.util.collection.ImmutableSet; +import org.jspecify.annotations.NonNull; + import static de.uka.ilkd.key.util.mergerule.MergeRuleUtils.clearSemisequent; import static de.uka.ilkd.key.util.mergerule.MergeRuleUtils.closeMergePartnerGoal; import static de.uka.ilkd.key.util.mergerule.MergeRuleUtils.getConjunctiveElementsFor; diff --git a/key.core/src/main/java/de/uka/ilkd/key/settings/SettingsConverter.java b/key.core/src/main/java/de/uka/ilkd/key/settings/SettingsConverter.java index d6ade095dec..8ddf8237bd0 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/settings/SettingsConverter.java +++ b/key.core/src/main/java/de/uka/ilkd/key/settings/SettingsConverter.java @@ -9,10 +9,11 @@ import java.util.Collection; import java.util.Properties; import java.util.stream.Collectors; -import org.jspecify.annotations.NonNull; import org.key_project.util.Streams; +import org.jspecify.annotations.NonNull; + /** * Utility class providing various methods to read properties. * diff --git a/key.core/src/main/java/de/uka/ilkd/key/smt/RuleAppSMT.java b/key.core/src/main/java/de/uka/ilkd/key/smt/RuleAppSMT.java index ac72c44409c..d2b58444d59 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/smt/RuleAppSMT.java +++ b/key.core/src/main/java/de/uka/ilkd/key/smt/RuleAppSMT.java @@ -1,7 +1,8 @@ +/* This file is part of KeY - https://key-project.org + * KeY is licensed under the GNU General Public License Version 2 + * SPDX-License-Identifier: GPL-2.0-only */ package de.uka.ilkd.key.smt; -import org.jspecify.annotations.NonNull; - import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.logic.Name; import de.uka.ilkd.key.logic.PosInOccurrence; @@ -13,6 +14,8 @@ import org.key_project.util.collection.ImmutableList; +import org.jspecify.annotations.NonNull; + /** * The rule application that is used when a goal is closed by means of an external solver. So far it * stores the rule that that has been used and a title containing some information for the user. diff --git a/key.core/src/main/java/de/uka/ilkd/key/smt/SMTSolverImplementation.java b/key.core/src/main/java/de/uka/ilkd/key/smt/SMTSolverImplementation.java index 8e04710c3e7..cf920273d82 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/smt/SMTSolverImplementation.java +++ b/key.core/src/main/java/de/uka/ilkd/key/smt/SMTSolverImplementation.java @@ -7,7 +7,6 @@ import java.util.Collection; import java.util.LinkedList; import java.util.concurrent.atomic.AtomicInteger; -import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.java.abstraction.KeYJavaType; @@ -22,6 +21,7 @@ import de.uka.ilkd.key.smt.solvertypes.SolverTypes; import de.uka.ilkd.key.taclettranslation.assumptions.TacletSetTranslation; +import org.jspecify.annotations.NonNull; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/key.core/src/main/java/de/uka/ilkd/key/smt/SmtLib2Translator.java b/key.core/src/main/java/de/uka/ilkd/key/smt/SmtLib2Translator.java index 56f2299237f..c26e32762fc 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/smt/SmtLib2Translator.java +++ b/key.core/src/main/java/de/uka/ilkd/key/smt/SmtLib2Translator.java @@ -4,11 +4,12 @@ package de.uka.ilkd.key.smt; import java.util.ArrayList; -import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.logic.sort.Sort; +import org.jspecify.annotations.Nullable; + /** * The translation for the SMT2-format. It nearly the same as for the SMT1-format. */ diff --git a/key.core/src/main/java/de/uka/ilkd/key/smt/communication/AbstractSolverSocket.java b/key.core/src/main/java/de/uka/ilkd/key/smt/communication/AbstractSolverSocket.java index 0075e8edb7a..d6ed1dfbb81 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/smt/communication/AbstractSolverSocket.java +++ b/key.core/src/main/java/de/uka/ilkd/key/smt/communication/AbstractSolverSocket.java @@ -4,11 +4,12 @@ package de.uka.ilkd.key.smt.communication; import java.io.IOException; -import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.smt.ModelExtractor; import de.uka.ilkd.key.smt.solvertypes.SolverType; +import org.jspecify.annotations.NonNull; + /** * The SolverSocket class describes the communication between the KeY and the SMT solver process. * This description is no longer part of the SolverType because in the case when we search for diff --git a/key.core/src/main/java/de/uka/ilkd/key/smt/communication/CVC4Socket.java b/key.core/src/main/java/de/uka/ilkd/key/smt/communication/CVC4Socket.java index 957f0a2536e..a459b33378e 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/smt/communication/CVC4Socket.java +++ b/key.core/src/main/java/de/uka/ilkd/key/smt/communication/CVC4Socket.java @@ -4,11 +4,12 @@ package de.uka.ilkd.key.smt.communication; import java.io.IOException; -import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.smt.ModelExtractor; import de.uka.ilkd.key.smt.SMTSolverResult; +import org.jspecify.annotations.NonNull; + public class CVC4Socket extends AbstractSolverSocket { public CVC4Socket(String name, ModelExtractor query) { diff --git a/key.core/src/main/java/de/uka/ilkd/key/smt/communication/CVC5Socket.java b/key.core/src/main/java/de/uka/ilkd/key/smt/communication/CVC5Socket.java index 6e3f6a6bfe5..6d7c47cf2d3 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/smt/communication/CVC5Socket.java +++ b/key.core/src/main/java/de/uka/ilkd/key/smt/communication/CVC5Socket.java @@ -4,11 +4,12 @@ package de.uka.ilkd.key.smt.communication; import java.io.IOException; -import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.smt.ModelExtractor; import de.uka.ilkd.key.smt.SMTSolverResult; +import org.jspecify.annotations.NonNull; + /** * Socket for CVC5 (...). */ diff --git a/key.core/src/main/java/de/uka/ilkd/key/smt/communication/ExternalProcessLauncher.java b/key.core/src/main/java/de/uka/ilkd/key/smt/communication/ExternalProcessLauncher.java index 7494d45ef54..9be54ba4bc9 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/smt/communication/ExternalProcessLauncher.java +++ b/key.core/src/main/java/de/uka/ilkd/key/smt/communication/ExternalProcessLauncher.java @@ -4,6 +4,7 @@ package de.uka.ilkd.key.smt.communication; import java.io.*; + import org.jspecify.annotations.NonNull; /** diff --git a/key.core/src/main/java/de/uka/ilkd/key/smt/communication/LegacyPipe.java b/key.core/src/main/java/de/uka/ilkd/key/smt/communication/LegacyPipe.java index 23d577c968b..a10a8acb9cc 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/smt/communication/LegacyPipe.java +++ b/key.core/src/main/java/de/uka/ilkd/key/smt/communication/LegacyPipe.java @@ -8,12 +8,13 @@ import java.nio.charset.StandardCharsets; import java.util.concurrent.BlockingQueue; import java.util.concurrent.LinkedBlockingQueue; -import org.jspecify.annotations.NonNull; -import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.smt.communication.SolverCommunication.Message; import de.uka.ilkd.key.smt.communication.SolverCommunication.MessageType; +import org.jspecify.annotations.NonNull; +import org.jspecify.annotations.Nullable; + /** * On each side of the pipe there are sender and receivers: **** Receiver ====<=Output======= Sender * ****************** KeY* Sender ======Input=>====== Receiver *External Process* **** Receiver diff --git a/key.core/src/main/java/de/uka/ilkd/key/smt/communication/Pipe.java b/key.core/src/main/java/de/uka/ilkd/key/smt/communication/Pipe.java index fa14a9f1cb9..004b93de1f9 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/smt/communication/Pipe.java +++ b/key.core/src/main/java/de/uka/ilkd/key/smt/communication/Pipe.java @@ -4,6 +4,7 @@ package de.uka.ilkd.key.smt.communication; import java.io.IOException; + import org.jspecify.annotations.NonNull; import org.jspecify.annotations.Nullable; diff --git a/key.core/src/main/java/de/uka/ilkd/key/smt/communication/SimplePipe.java b/key.core/src/main/java/de/uka/ilkd/key/smt/communication/SimplePipe.java index 7bd67ae49de..2e5d3e56c98 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/smt/communication/SimplePipe.java +++ b/key.core/src/main/java/de/uka/ilkd/key/smt/communication/SimplePipe.java @@ -5,9 +5,9 @@ import java.io.*; import java.nio.charset.StandardCharsets; + import org.jspecify.annotations.NonNull; import org.jspecify.annotations.Nullable; - import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/key.core/src/main/java/de/uka/ilkd/key/smt/communication/TeeReader.java b/key.core/src/main/java/de/uka/ilkd/key/smt/communication/TeeReader.java index 0a9e369ebea..f076bba11a8 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/smt/communication/TeeReader.java +++ b/key.core/src/main/java/de/uka/ilkd/key/smt/communication/TeeReader.java @@ -6,6 +6,7 @@ import java.io.IOException; import java.io.Reader; import java.io.Writer; + import org.jspecify.annotations.NonNull; /** diff --git a/key.core/src/main/java/de/uka/ilkd/key/smt/communication/TeeWriter.java b/key.core/src/main/java/de/uka/ilkd/key/smt/communication/TeeWriter.java index 23317141983..9849a572a36 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/smt/communication/TeeWriter.java +++ b/key.core/src/main/java/de/uka/ilkd/key/smt/communication/TeeWriter.java @@ -5,6 +5,7 @@ import java.io.IOException; import java.io.Writer; + import org.jspecify.annotations.NonNull; diff --git a/key.core/src/main/java/de/uka/ilkd/key/smt/communication/Z3CESocket.java b/key.core/src/main/java/de/uka/ilkd/key/smt/communication/Z3CESocket.java index ee3c811244f..648c4968109 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/smt/communication/Z3CESocket.java +++ b/key.core/src/main/java/de/uka/ilkd/key/smt/communication/Z3CESocket.java @@ -4,11 +4,12 @@ package de.uka.ilkd.key.smt.communication; import java.io.IOException; -import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.smt.ModelExtractor; import de.uka.ilkd.key.smt.SMTSolverResult; +import org.jspecify.annotations.NonNull; + public class Z3CESocket extends AbstractSolverSocket { public Z3CESocket(String name, ModelExtractor query) { diff --git a/key.core/src/main/java/de/uka/ilkd/key/smt/communication/Z3Socket.java b/key.core/src/main/java/de/uka/ilkd/key/smt/communication/Z3Socket.java index dd4aade3256..1ff6deac753 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/smt/communication/Z3Socket.java +++ b/key.core/src/main/java/de/uka/ilkd/key/smt/communication/Z3Socket.java @@ -4,11 +4,12 @@ package de.uka.ilkd.key.smt.communication; import java.io.IOException; -import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.smt.ModelExtractor; import de.uka.ilkd.key.smt.SMTSolverResult; +import org.jspecify.annotations.NonNull; + public class Z3Socket extends AbstractSolverSocket { public Z3Socket(String name, ModelExtractor query) { diff --git a/key.core/src/main/java/de/uka/ilkd/key/smt/newsmt2/MasterHandler.java b/key.core/src/main/java/de/uka/ilkd/key/smt/newsmt2/MasterHandler.java index b9986a49dde..cbc58e552f6 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/smt/newsmt2/MasterHandler.java +++ b/key.core/src/main/java/de/uka/ilkd/key/smt/newsmt2/MasterHandler.java @@ -14,7 +14,6 @@ import java.util.Map.Entry; import java.util.Properties; import java.util.Set; -import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.logic.Term; diff --git a/key.core/src/main/java/de/uka/ilkd/key/smt/newsmt2/ModularSMTLib2Translator.java b/key.core/src/main/java/de/uka/ilkd/key/smt/newsmt2/ModularSMTLib2Translator.java index 7907234e7d0..1879b1581ad 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/smt/newsmt2/ModularSMTLib2Translator.java +++ b/key.core/src/main/java/de/uka/ilkd/key/smt/newsmt2/ModularSMTLib2Translator.java @@ -10,7 +10,6 @@ import java.util.Arrays; import java.util.LinkedList; import java.util.List; -import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.logic.Sequent; @@ -21,6 +20,7 @@ import de.uka.ilkd.key.smt.SMTTranslator; import de.uka.ilkd.key.smt.newsmt2.SExpr.Type; +import org.jspecify.annotations.Nullable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/key.core/src/main/java/de/uka/ilkd/key/smt/newsmt2/SMTHandlerServices.java b/key.core/src/main/java/de/uka/ilkd/key/smt/newsmt2/SMTHandlerServices.java index f1592323072..47ef5b2f33b 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/smt/newsmt2/SMTHandlerServices.java +++ b/key.core/src/main/java/de/uka/ilkd/key/smt/newsmt2/SMTHandlerServices.java @@ -12,13 +12,13 @@ import java.nio.charset.StandardCharsets; import java.util.*; import java.util.concurrent.ConcurrentHashMap; -import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.smt.solvertypes.SolverPropertiesLoader; import org.key_project.util.Streams; +import org.jspecify.annotations.NonNull; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/key.core/src/main/java/de/uka/ilkd/key/smt/solvertypes/SolverType.java b/key.core/src/main/java/de/uka/ilkd/key/smt/solvertypes/SolverType.java index c5b29744e74..d7758fd4298 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/smt/solvertypes/SolverType.java +++ b/key.core/src/main/java/de/uka/ilkd/key/smt/solvertypes/SolverType.java @@ -16,13 +16,13 @@ package de.uka.ilkd.key.smt.solvertypes; -import org.jspecify.annotations.NonNull; -import org.jspecify.annotations.Nullable; - import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.smt.*; import de.uka.ilkd.key.smt.communication.AbstractSolverSocket; +import org.jspecify.annotations.NonNull; +import org.jspecify.annotations.Nullable; + /** * This interface is used for modeling different solvers. It provides methods that encode diff --git a/key.core/src/main/java/de/uka/ilkd/key/smt/solvertypes/SolverTypeImplementation.java b/key.core/src/main/java/de/uka/ilkd/key/smt/solvertypes/SolverTypeImplementation.java index 14a806325fd..adf815fd951 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/smt/solvertypes/SolverTypeImplementation.java +++ b/key.core/src/main/java/de/uka/ilkd/key/smt/solvertypes/SolverTypeImplementation.java @@ -7,8 +7,6 @@ import java.lang.reflect.InvocationTargetException; import java.nio.file.Paths; import java.util.Arrays; -import org.jspecify.annotations.NonNull; -import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.smt.*; @@ -16,6 +14,8 @@ import de.uka.ilkd.key.smt.communication.Z3Socket; import de.uka.ilkd.key.smt.newsmt2.ModularSMTLib2Translator; +import org.jspecify.annotations.NonNull; +import org.jspecify.annotations.Nullable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/key.core/src/main/java/de/uka/ilkd/key/smt/solvertypes/SolverTypes.java b/key.core/src/main/java/de/uka/ilkd/key/smt/solvertypes/SolverTypes.java index 54e646d3dda..7677ca1bc4d 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/smt/solvertypes/SolverTypes.java +++ b/key.core/src/main/java/de/uka/ilkd/key/smt/solvertypes/SolverTypes.java @@ -4,6 +4,7 @@ package de.uka.ilkd.key.smt.solvertypes; import java.util.*; + import org.jspecify.annotations.NonNull; /** diff --git a/key.core/src/main/java/de/uka/ilkd/key/speclang/PositionedString.java b/key.core/src/main/java/de/uka/ilkd/key/speclang/PositionedString.java index 6ace599eb68..4c41fcd4eea 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/speclang/PositionedString.java +++ b/key.core/src/main/java/de/uka/ilkd/key/speclang/PositionedString.java @@ -5,7 +5,6 @@ import java.net.URI; import java.util.Objects; -import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.java.Position; import de.uka.ilkd.key.logic.label.TermLabel; @@ -13,6 +12,8 @@ import org.key_project.util.collection.ImmutableArray; +import org.jspecify.annotations.NonNull; + /** * A string with associated position information (file and line number). The position information is * used for error reporting. diff --git a/key.core/src/main/java/de/uka/ilkd/key/speclang/SpecificationElement.java b/key.core/src/main/java/de/uka/ilkd/key/speclang/SpecificationElement.java index 0e2e2d4e880..9fec83968fd 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/speclang/SpecificationElement.java +++ b/key.core/src/main/java/de/uka/ilkd/key/speclang/SpecificationElement.java @@ -4,13 +4,14 @@ package de.uka.ilkd.key.speclang; import java.util.function.UnaryOperator; -import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.java.abstraction.KeYJavaType; import de.uka.ilkd.key.java.declaration.modifier.VisibilityModifier; import de.uka.ilkd.key.logic.Term; +import org.jspecify.annotations.Nullable; + /** * Common superinterface of all constructs created by the specification language front ends and diff --git a/key.core/src/main/java/de/uka/ilkd/key/speclang/jml/JMLUtils.java b/key.core/src/main/java/de/uka/ilkd/key/speclang/jml/JMLUtils.java index f6035d985b8..0c37bd72c11 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/speclang/jml/JMLUtils.java +++ b/key.core/src/main/java/de/uka/ilkd/key/speclang/jml/JMLUtils.java @@ -5,6 +5,7 @@ import java.util.Set; import java.util.TreeSet; + import org.jspecify.annotations.NonNull; @Deprecated diff --git a/key.core/src/main/java/de/uka/ilkd/key/speclang/jml/pretranslation/TextualJMLConstruct.java b/key.core/src/main/java/de/uka/ilkd/key/speclang/jml/pretranslation/TextualJMLConstruct.java index a7d3ce8a25c..8e3a0d2505d 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/speclang/jml/pretranslation/TextualJMLConstruct.java +++ b/key.core/src/main/java/de/uka/ilkd/key/speclang/jml/pretranslation/TextualJMLConstruct.java @@ -6,7 +6,6 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; -import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.java.Position; import de.uka.ilkd.key.ldt.HeapLDT; @@ -19,6 +18,7 @@ import org.key_project.util.collection.ImmutableList; import org.antlr.v4.runtime.ParserRuleContext; +import org.jspecify.annotations.NonNull; /** * Objects of this type represent the various JML specification constructs in textual, unprocessed diff --git a/key.core/src/main/java/de/uka/ilkd/key/speclang/jml/pretranslation/TextualJMLDepends.java b/key.core/src/main/java/de/uka/ilkd/key/speclang/jml/pretranslation/TextualJMLDepends.java index 9a29424e26c..b3577938355 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/speclang/jml/pretranslation/TextualJMLDepends.java +++ b/key.core/src/main/java/de/uka/ilkd/key/speclang/jml/pretranslation/TextualJMLDepends.java @@ -5,7 +5,6 @@ import java.util.LinkedHashMap; import java.util.Map; -import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.ldt.HeapLDT; import de.uka.ilkd.key.logic.Name; @@ -14,6 +13,8 @@ import org.key_project.util.collection.ImmutableList; import org.key_project.util.collection.ImmutableSLList; +import org.jspecify.annotations.NonNull; + /** * A JML depends / accessible clause for a model field in textual form. Note that such clauses for * *methods* are part of TextualJMLSpecCase. diff --git a/key.core/src/main/java/de/uka/ilkd/key/speclang/jml/pretranslation/TextualJMLLoopSpec.java b/key.core/src/main/java/de/uka/ilkd/key/speclang/jml/pretranslation/TextualJMLLoopSpec.java index 62cdc9f2295..239218a3c0e 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/speclang/jml/pretranslation/TextualJMLLoopSpec.java +++ b/key.core/src/main/java/de/uka/ilkd/key/speclang/jml/pretranslation/TextualJMLLoopSpec.java @@ -5,7 +5,6 @@ import java.util.*; import java.util.stream.Collectors; -import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.ldt.HeapLDT; import de.uka.ilkd.key.logic.Name; @@ -14,6 +13,8 @@ import org.key_project.util.collection.ImmutableList; import org.key_project.util.collection.ImmutableSLList; +import org.jspecify.annotations.Nullable; + /** * A JML loop specification (invariant, assignable clause, decreases clause, ...) in textual form. */ diff --git a/key.core/src/main/java/de/uka/ilkd/key/speclang/jml/pretranslation/TextualJMLMergePointDecl.java b/key.core/src/main/java/de/uka/ilkd/key/speclang/jml/pretranslation/TextualJMLMergePointDecl.java index 62e42d2420f..3670536c07b 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/speclang/jml/pretranslation/TextualJMLMergePointDecl.java +++ b/key.core/src/main/java/de/uka/ilkd/key/speclang/jml/pretranslation/TextualJMLMergePointDecl.java @@ -4,14 +4,13 @@ package de.uka.ilkd.key.speclang.jml.pretranslation; import java.util.Objects; -import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.speclang.njml.JmlParser; -import org.jspecify.annotations.NullMarked; import org.key_project.util.collection.ImmutableList; -import org.jspecify.annotations.NonNull; +import org.jspecify.annotations.NullMarked; + /** * A JML merge point declaration in textual form. @@ -25,7 +24,8 @@ public final class TextualJMLMergePointDecl extends TextualJMLConstruct { private final JmlParser.Merge_point_statementContext mergeProc; - public TextualJMLMergePointDecl(ImmutableList mods, JmlParser.Merge_point_statementContext mergeProc) { + public TextualJMLMergePointDecl(ImmutableList mods, + JmlParser.Merge_point_statementContext mergeProc) { super(mods); this.mergeProc = mergeProc; setPosition(mergeProc); @@ -38,7 +38,7 @@ public JmlParser.Merge_point_statementContext getMergeProc() { @Override public String toString() { return "TextualJMLMergePointDecl{" + "mergeProc=" + mergeProc.getText() + ", mods=" + mods - + ", name='" + name + '\'' + '}'; + + ", name='" + name + '\'' + '}'; } @Override diff --git a/key.core/src/main/java/de/uka/ilkd/key/speclang/jml/pretranslation/TextualJMLSpecCase.java b/key.core/src/main/java/de/uka/ilkd/key/speclang/jml/pretranslation/TextualJMLSpecCase.java index 73ea075cfdc..5e0b9e960fa 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/speclang/jml/pretranslation/TextualJMLSpecCase.java +++ b/key.core/src/main/java/de/uka/ilkd/key/speclang/jml/pretranslation/TextualJMLSpecCase.java @@ -7,8 +7,6 @@ import java.util.List; import java.util.Objects; import java.util.stream.Collectors; -import org.jspecify.annotations.NonNull; -import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.ldt.HeapLDT; import de.uka.ilkd.key.logic.Name; @@ -18,6 +16,8 @@ import org.key_project.util.collection.ImmutableList; import org.antlr.v4.runtime.ParserRuleContext; +import org.jspecify.annotations.NonNull; +import org.jspecify.annotations.Nullable; import static de.uka.ilkd.key.speclang.jml.pretranslation.TextualJMLSpecCase.Clause.*; import static de.uka.ilkd.key.speclang.jml.pretranslation.TextualJMLSpecCase.ClauseHd.*; diff --git a/key.core/src/main/java/de/uka/ilkd/key/speclang/jml/translation/Context.java b/key.core/src/main/java/de/uka/ilkd/key/speclang/jml/translation/Context.java index e2c8cec33ce..e065b75d7aa 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/speclang/jml/translation/Context.java +++ b/key.core/src/main/java/de/uka/ilkd/key/speclang/jml/translation/Context.java @@ -3,8 +3,6 @@ * SPDX-License-Identifier: GPL-2.0-only */ package de.uka.ilkd.key.speclang.jml.translation; -import org.jspecify.annotations.NonNull; -import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.java.abstraction.KeYJavaType; import de.uka.ilkd.key.logic.TermBuilder; import de.uka.ilkd.key.logic.op.IProgramMethod; @@ -12,6 +10,9 @@ import de.uka.ilkd.key.speclang.jml.JMLInfoExtractor; import de.uka.ilkd.key.speclang.njml.SpecMathMode; +import org.jspecify.annotations.NonNull; +import org.jspecify.annotations.Nullable; + /** * Common information that is needed almost everywhere during translation. Class is immutable. * diff --git a/key.core/src/main/java/de/uka/ilkd/key/speclang/jml/translation/JMLSpecFactory.java b/key.core/src/main/java/de/uka/ilkd/key/speclang/jml/translation/JMLSpecFactory.java index d38a5290a0e..5653bfbb809 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/speclang/jml/translation/JMLSpecFactory.java +++ b/key.core/src/main/java/de/uka/ilkd/key/speclang/jml/translation/JMLSpecFactory.java @@ -6,8 +6,6 @@ import java.util.*; import java.util.stream.Collectors; import java.util.stream.Stream; -import org.jspecify.annotations.NonNull; -import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.axiom_abstraction.predicateabstraction.AbstractionPredicate; import de.uka.ilkd.key.java.*; @@ -50,6 +48,8 @@ import org.key_project.util.collection.*; import org.antlr.v4.runtime.Token; +import org.jspecify.annotations.NonNull; +import org.jspecify.annotations.Nullable; import static de.uka.ilkd.key.speclang.jml.pretranslation.TextualJMLSpecCase.Clause.DIVERGES; import static de.uka.ilkd.key.speclang.jml.pretranslation.TextualJMLSpecCase.Clause.SIGNALS; diff --git a/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/ContractClauses.java b/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/ContractClauses.java index daa9a36c296..b3070b6ea1f 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/ContractClauses.java +++ b/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/ContractClauses.java @@ -7,7 +7,6 @@ import java.util.List; import java.util.Map; import java.util.stream.Collectors; -import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.java.Label; import de.uka.ilkd.key.logic.Term; @@ -15,6 +14,8 @@ import de.uka.ilkd.key.util.LinkedHashMap; import de.uka.ilkd.key.util.Pair; +import org.jspecify.annotations.Nullable; + class ContractClauses { public @Nullable Term measuredBy; public @Nullable Term decreases; diff --git a/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/DoubleHandler.java b/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/DoubleHandler.java index 5cbfd3fc99f..9d4d62ae557 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/DoubleHandler.java +++ b/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/DoubleHandler.java @@ -5,7 +5,6 @@ import java.util.EnumMap; import java.util.Map; -import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.java.abstraction.KeYJavaType; @@ -14,6 +13,8 @@ import de.uka.ilkd.key.ldt.DoubleLDT; import de.uka.ilkd.key.speclang.njml.OverloadedOperatorHandler.JMLOperator; +import org.jspecify.annotations.Nullable; + import static de.uka.ilkd.key.speclang.njml.OverloadedOperatorHandler.JMLOperator.*; public class DoubleHandler extends LDTHandler { diff --git a/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/FloatHandler.java b/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/FloatHandler.java index 95406f9b57b..4d8e800fa42 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/FloatHandler.java +++ b/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/FloatHandler.java @@ -5,7 +5,6 @@ import java.util.EnumMap; import java.util.Map; -import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.java.abstraction.KeYJavaType; @@ -14,6 +13,8 @@ import de.uka.ilkd.key.ldt.FloatLDT; import de.uka.ilkd.key.speclang.njml.OverloadedOperatorHandler.JMLOperator; +import org.jspecify.annotations.Nullable; + import static de.uka.ilkd.key.speclang.njml.OverloadedOperatorHandler.JMLOperator.*; public class FloatHandler extends LDTHandler { diff --git a/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/IntegerHandler.java b/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/IntegerHandler.java index 1f3891ff1e1..da8879d5a43 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/IntegerHandler.java +++ b/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/IntegerHandler.java @@ -6,13 +6,14 @@ import java.util.EnumMap; import java.util.IdentityHashMap; import java.util.Map; -import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.java.abstraction.PrimitiveType; import de.uka.ilkd.key.java.abstraction.Type; import de.uka.ilkd.key.speclang.njml.OverloadedOperatorHandler.JMLOperator; +import org.jspecify.annotations.Nullable; + import static de.uka.ilkd.key.speclang.njml.OverloadedOperatorHandler.JMLOperator.*; public class IntegerHandler extends LDTHandler { diff --git a/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/JmlCheck.java b/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/JmlCheck.java index 61f255443c9..7f2335831f9 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/JmlCheck.java +++ b/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/JmlCheck.java @@ -4,11 +4,11 @@ package de.uka.ilkd.key.speclang.njml; import java.util.List; -import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.speclang.PositionedString; import org.antlr.v4.runtime.ParserRuleContext; +import org.jspecify.annotations.NonNull; /** * Interface describes a syntactical check on JML parse trees. diff --git a/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/JmlChecks.java b/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/JmlChecks.java index e6779e45055..b7c2e060ffa 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/JmlChecks.java +++ b/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/JmlChecks.java @@ -6,12 +6,12 @@ import java.util.ArrayList; import java.util.LinkedList; import java.util.List; -import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.parser.Location; import de.uka.ilkd.key.speclang.PositionedString; import org.antlr.v4.runtime.ParserRuleContext; +import org.jspecify.annotations.NonNull; /** * Facade for implementing syntactical JML syntax checks. diff --git a/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/JmlFacade.java b/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/JmlFacade.java index 4ddaf846704..80b93be0ce9 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/JmlFacade.java +++ b/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/JmlFacade.java @@ -4,7 +4,6 @@ package de.uka.ilkd.key.speclang.njml; import java.net.URI; -import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.java.Position; import de.uka.ilkd.key.speclang.PositionedString; @@ -14,6 +13,7 @@ import org.antlr.v4.runtime.CharStreams; import org.antlr.v4.runtime.CommonTokenStream; import org.antlr.v4.runtime.ParserRuleContext; +import org.jspecify.annotations.NonNull; /** * This facade provides facilities for the creation of lexer and parser of JML. It is the diff --git a/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/JmlIO.java b/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/JmlIO.java index c6564d03dfe..4d59650f6f2 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/JmlIO.java +++ b/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/JmlIO.java @@ -4,8 +4,6 @@ package de.uka.ilkd.key.speclang.njml; import java.util.Map; -import org.jspecify.annotations.NonNull; -import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.java.Label; import de.uka.ilkd.key.java.Services; @@ -27,6 +25,8 @@ import org.key_project.util.collection.ImmutableSLList; import org.antlr.v4.runtime.ParserRuleContext; +import org.jspecify.annotations.NonNull; +import org.jspecify.annotations.Nullable; /** * Stateful service for translating JML into KeY entities. diff --git a/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/JmlMarkerDecision.java b/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/JmlMarkerDecision.java index 74d8c5d8e8e..1651ecfad63 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/JmlMarkerDecision.java +++ b/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/JmlMarkerDecision.java @@ -8,6 +8,7 @@ import java.util.HashSet; import java.util.Set; import java.util.stream.Collectors; + import org.jspecify.annotations.NonNull; /** diff --git a/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/JmlTermFactory.java b/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/JmlTermFactory.java index f4115c24bd6..5fba719ee4b 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/JmlTermFactory.java +++ b/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/JmlTermFactory.java @@ -5,8 +5,6 @@ import java.util.*; import java.util.function.BiFunction; -import org.jspecify.annotations.NonNull; -import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.java.JavaInfo; import de.uka.ilkd.key.java.Label; @@ -39,6 +37,8 @@ import org.key_project.util.collection.ImmutableSLList; import org.antlr.runtime.Token; +import org.jspecify.annotations.NonNull; +import org.jspecify.annotations.Nullable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/LDTHandler.java b/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/LDTHandler.java index d28297bdf1a..0ab032bc135 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/LDTHandler.java +++ b/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/LDTHandler.java @@ -4,7 +4,6 @@ package de.uka.ilkd.key.speclang.njml; import java.util.Map; -import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.java.abstraction.KeYJavaType; @@ -17,6 +16,8 @@ import de.uka.ilkd.key.speclang.translation.SLExpression; import de.uka.ilkd.key.speclang.translation.SLTranslationException; +import org.jspecify.annotations.Nullable; + public abstract class LDTHandler implements JMLOperatorHandler { /** * Pair (KJT, Operator) diff --git a/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/LabeledParserRuleContext.java b/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/LabeledParserRuleContext.java index cadcb179ed0..8d4074791ac 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/LabeledParserRuleContext.java +++ b/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/LabeledParserRuleContext.java @@ -4,8 +4,6 @@ package de.uka.ilkd.key.speclang.njml; import java.net.URI; -import org.jspecify.annotations.NonNull; -import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.logic.label.OriginTermLabel; import de.uka.ilkd.key.logic.label.OriginTermLabelFactory; @@ -13,6 +11,8 @@ import de.uka.ilkd.key.util.MiscTools; import org.antlr.v4.runtime.ParserRuleContext; +import org.jspecify.annotations.NonNull; +import org.jspecify.annotations.Nullable; /** * This class maps a {@link ParserRuleContext} to a {@link TermLabel}. diff --git a/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/OverloadedOperatorHandler.java b/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/OverloadedOperatorHandler.java index c9d719d5cad..6d2d73e21a1 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/OverloadedOperatorHandler.java +++ b/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/OverloadedOperatorHandler.java @@ -4,7 +4,6 @@ package de.uka.ilkd.key.speclang.njml; import java.util.*; -import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.ldt.LocSetLDT; @@ -14,6 +13,8 @@ import de.uka.ilkd.key.speclang.translation.SLExpression; import de.uka.ilkd.key.speclang.translation.SLTranslationException; +import org.jspecify.annotations.Nullable; + /** * This class is used to resolve arithmetic operations to {@link SLExpression}s. These are overladed * for different primitive types. diff --git a/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/PreParser.java b/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/PreParser.java index 866c9674baf..fa88eebbd8c 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/PreParser.java +++ b/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/PreParser.java @@ -6,7 +6,6 @@ import java.net.URI; import java.util.ArrayList; import java.util.List; -import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.java.Position; import de.uka.ilkd.key.parser.Location; @@ -18,6 +17,7 @@ import org.key_project.util.collection.ImmutableSLList; import org.antlr.v4.runtime.ParserRuleContext; +import org.jspecify.annotations.NonNull; public class PreParser { /** warnings */ diff --git a/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/TextualTranslator.java b/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/TextualTranslator.java index b1caf96016b..20ecef050c2 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/TextualTranslator.java +++ b/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/TextualTranslator.java @@ -3,8 +3,6 @@ * SPDX-License-Identifier: GPL-2.0-only */ package de.uka.ilkd.key.speclang.njml; -import org.jspecify.annotations.Nullable; - import de.uka.ilkd.key.ldt.HeapLDT; import de.uka.ilkd.key.logic.Name; import de.uka.ilkd.key.logic.label.OriginTermLabel; diff --git a/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/Translator.java b/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/Translator.java index e5b2c7bdde0..15de4187522 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/Translator.java +++ b/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/Translator.java @@ -8,8 +8,6 @@ import java.util.Map; import java.util.Optional; import java.util.stream.Collectors; -import org.jspecify.annotations.NonNull; -import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.java.JavaInfo; import de.uka.ilkd.key.java.Label; @@ -48,6 +46,8 @@ import org.antlr.v4.runtime.ParserRuleContext; import org.antlr.v4.runtime.Token; import org.antlr.v4.runtime.tree.TerminalNode; +import org.jspecify.annotations.NonNull; +import org.jspecify.annotations.Nullable; import static de.uka.ilkd.key.speclang.njml.OverloadedOperatorHandler.JMLOperator.*; import static java.lang.String.format; diff --git a/key.core/src/main/java/de/uka/ilkd/key/speclang/translation/SLExceptionFactory.java b/key.core/src/main/java/de/uka/ilkd/key/speclang/translation/SLExceptionFactory.java index de244149334..f9b4e3ee6eb 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/speclang/translation/SLExceptionFactory.java +++ b/key.core/src/main/java/de/uka/ilkd/key/speclang/translation/SLExceptionFactory.java @@ -6,7 +6,6 @@ import java.net.URI; import java.util.LinkedList; import java.util.List; -import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.java.Position; import de.uka.ilkd.key.parser.Location; @@ -15,6 +14,7 @@ import org.antlr.v4.runtime.Parser; import org.antlr.v4.runtime.Token; +import org.jspecify.annotations.NonNull; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/key.core/src/main/java/de/uka/ilkd/key/speclang/translation/SLExpression.java b/key.core/src/main/java/de/uka/ilkd/key/speclang/translation/SLExpression.java index e572b153035..5e288e1ef51 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/speclang/translation/SLExpression.java +++ b/key.core/src/main/java/de/uka/ilkd/key/speclang/translation/SLExpression.java @@ -3,8 +3,6 @@ * SPDX-License-Identifier: GPL-2.0-only */ package de.uka.ilkd.key.speclang.translation; -import org.jspecify.annotations.NonNull; - import de.uka.ilkd.key.java.abstraction.KeYJavaType; import de.uka.ilkd.key.logic.Term; import de.uka.ilkd.key.logic.sort.Sort; diff --git a/key.core/src/main/java/de/uka/ilkd/key/speclang/translation/SLTranslationException.java b/key.core/src/main/java/de/uka/ilkd/key/speclang/translation/SLTranslationException.java index 0164980e94c..56997dc624c 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/speclang/translation/SLTranslationException.java +++ b/key.core/src/main/java/de/uka/ilkd/key/speclang/translation/SLTranslationException.java @@ -5,13 +5,14 @@ import java.net.MalformedURLException; import java.net.URI; -import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.java.Position; import de.uka.ilkd.key.parser.Location; import de.uka.ilkd.key.proof.init.ProofInputException; import de.uka.ilkd.key.util.parsing.HasLocation; +import org.jspecify.annotations.Nullable; + public class SLTranslationException extends ProofInputException implements HasLocation { protected final Location location; diff --git a/key.core/src/main/java/de/uka/ilkd/key/strategy/NumberRuleAppCost.java b/key.core/src/main/java/de/uka/ilkd/key/strategy/NumberRuleAppCost.java index 5e00c94bcad..0d40797bbb1 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/strategy/NumberRuleAppCost.java +++ b/key.core/src/main/java/de/uka/ilkd/key/strategy/NumberRuleAppCost.java @@ -3,8 +3,6 @@ * SPDX-License-Identifier: GPL-2.0-only */ package de.uka.ilkd.key.strategy; -import org.jspecify.annotations.NonNull; - import de.uka.ilkd.key.util.Debug; import org.key_project.util.LRUCache; diff --git a/key.core/src/main/java/de/uka/ilkd/key/strategy/QueueRuleApplicationManager.java b/key.core/src/main/java/de/uka/ilkd/key/strategy/QueueRuleApplicationManager.java index fb656eb603d..2e944d4515b 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/strategy/QueueRuleApplicationManager.java +++ b/key.core/src/main/java/de/uka/ilkd/key/strategy/QueueRuleApplicationManager.java @@ -6,7 +6,6 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.concurrent.atomic.AtomicLong; -import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.logic.PosInOccurrence; import de.uka.ilkd.key.proof.Goal; @@ -18,6 +17,8 @@ import org.key_project.util.collection.ImmutableList; import org.key_project.util.collection.ImmutableSLList; +import org.jspecify.annotations.Nullable; + /** * Implementation of {@link AutomatedRuleApplicationManager} that stores possible {@link RuleApp}s * in a priority queue. The element with highest priority in the queue can be obtained via diff --git a/key.core/src/main/java/de/uka/ilkd/key/strategy/feature/AppliedRuleAppsNameCache.java b/key.core/src/main/java/de/uka/ilkd/key/strategy/feature/AppliedRuleAppsNameCache.java index 74258d981eb..0b1c9714213 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/strategy/feature/AppliedRuleAppsNameCache.java +++ b/key.core/src/main/java/de/uka/ilkd/key/strategy/feature/AppliedRuleAppsNameCache.java @@ -5,7 +5,6 @@ import java.util.*; import java.util.concurrent.locks.ReentrantReadWriteLock; -import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.logic.Name; import de.uka.ilkd.key.proof.Node; @@ -14,6 +13,8 @@ import org.key_project.util.LRUCache; +import org.jspecify.annotations.NonNull; + /** * Establishes a cache for the applied rule apps to query them by name. * See the get method for additional required constraints for correctness. diff --git a/key.core/src/main/java/de/uka/ilkd/key/taclettranslation/lemma/TacletProofObligationInput.java b/key.core/src/main/java/de/uka/ilkd/key/taclettranslation/lemma/TacletProofObligationInput.java index dbb3b671887..a2ea2b34207 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/taclettranslation/lemma/TacletProofObligationInput.java +++ b/key.core/src/main/java/de/uka/ilkd/key/taclettranslation/lemma/TacletProofObligationInput.java @@ -6,7 +6,6 @@ import java.io.File; import java.io.IOException; import java.util.*; -import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.java.abstraction.KeYJavaType; import de.uka.ilkd.key.logic.Name; @@ -21,6 +20,7 @@ import org.key_project.util.collection.DefaultImmutableSet; import org.key_project.util.collection.ImmutableSet; +import org.jspecify.annotations.Nullable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/key.core/src/main/java/de/uka/ilkd/key/taclettranslation/lemma/TacletSoundnessPOLoader.java b/key.core/src/main/java/de/uka/ilkd/key/taclettranslation/lemma/TacletSoundnessPOLoader.java index 478df4d43d3..fdbf739c50f 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/taclettranslation/lemma/TacletSoundnessPOLoader.java +++ b/key.core/src/main/java/de/uka/ilkd/key/taclettranslation/lemma/TacletSoundnessPOLoader.java @@ -4,7 +4,6 @@ package de.uka.ilkd.key.taclettranslation.lemma; import java.util.*; -import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.proof.CompoundProof; import de.uka.ilkd.key.proof.Proof; @@ -21,6 +20,8 @@ import org.key_project.util.collection.ImmutableList; import org.key_project.util.collection.ImmutableSet; +import org.jspecify.annotations.Nullable; + public class TacletSoundnessPOLoader { private final boolean loadAsLemmata; diff --git a/key.core/src/main/java/de/uka/ilkd/key/util/ExceptionTools.java b/key.core/src/main/java/de/uka/ilkd/key/util/ExceptionTools.java index b4dfc40a7f5..b32cbd03e75 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/util/ExceptionTools.java +++ b/key.core/src/main/java/de/uka/ilkd/key/util/ExceptionTools.java @@ -7,8 +7,6 @@ import java.util.Optional; import java.util.regex.Matcher; import java.util.regex.Pattern; -import org.jspecify.annotations.NonNull; -import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.java.Position; import de.uka.ilkd.key.parser.Location; @@ -17,6 +15,9 @@ import de.uka.ilkd.key.parser.proofjava.TokenMgrError; import de.uka.ilkd.key.util.parsing.HasLocation; +import org.jspecify.annotations.NonNull; +import org.jspecify.annotations.Nullable; + /** * Various utility methods related to exceptions. diff --git a/key.core/src/main/java/de/uka/ilkd/key/util/KeYTypeUtil.java b/key.core/src/main/java/de/uka/ilkd/key/util/KeYTypeUtil.java index 1c352da2c9b..e87e74b8cce 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/util/KeYTypeUtil.java +++ b/key.core/src/main/java/de/uka/ilkd/key/util/KeYTypeUtil.java @@ -15,10 +15,11 @@ import de.uka.ilkd.key.java.reference.TypeReference; import de.uka.ilkd.key.logic.op.IProgramMethod; -import org.jspecify.annotations.Nullable; import org.key_project.util.collection.ImmutableList; import org.key_project.util.java.CollectionUtil; +import org.jspecify.annotations.Nullable; + /** * Provides utility methods which makes it easier to analyze the type hierarchy of * {@link KeYJavaType} instances with help of given {@link Services}. diff --git a/key.core/src/main/java/de/uka/ilkd/key/util/MiscTools.java b/key.core/src/main/java/de/uka/ilkd/key/util/MiscTools.java index f54ce69a6b6..c53183cb6ce 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/util/MiscTools.java +++ b/key.core/src/main/java/de/uka/ilkd/key/util/MiscTools.java @@ -16,7 +16,6 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.zip.ZipFile; -import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.java.*; import de.uka.ilkd.key.java.declaration.VariableSpecification; @@ -50,6 +49,7 @@ import org.antlr.v4.runtime.IntStream; import org.antlr.v4.runtime.TokenSource; +import org.jspecify.annotations.Nullable; import recoder.io.ArchiveDataLocation; import recoder.io.DataFileLocation; import recoder.io.DataLocation; diff --git a/key.core/src/main/java/de/uka/ilkd/key/util/RecognitionException.java b/key.core/src/main/java/de/uka/ilkd/key/util/RecognitionException.java index 2441723e42d..4880e779dce 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/util/RecognitionException.java +++ b/key.core/src/main/java/de/uka/ilkd/key/util/RecognitionException.java @@ -4,13 +4,13 @@ package de.uka.ilkd.key.util; import java.net.MalformedURLException; -import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.java.Position; import de.uka.ilkd.key.parser.Location; import de.uka.ilkd.key.util.parsing.HasLocation; import org.antlr.v4.runtime.IntStream; +import org.jspecify.annotations.Nullable; /** * @author Alexander Weigl diff --git a/key.core/src/main/java/de/uka/ilkd/key/util/mergerule/MergeRuleUtils.java b/key.core/src/main/java/de/uka/ilkd/key/util/mergerule/MergeRuleUtils.java index 0169203c498..0d023fa3d02 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/util/mergerule/MergeRuleUtils.java +++ b/key.core/src/main/java/de/uka/ilkd/key/util/mergerule/MergeRuleUtils.java @@ -6,7 +6,6 @@ import java.io.StringReader; import java.util.*; import java.util.stream.Collectors; -import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.axiom_abstraction.predicateabstraction.AbstractionPredicate; import de.uka.ilkd.key.java.*; @@ -37,6 +36,7 @@ import org.key_project.util.collection.*; +import org.jspecify.annotations.NonNull; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/key.core/src/main/java/de/uka/ilkd/key/util/package-info.java b/key.core/src/main/java/de/uka/ilkd/key/util/package-info.java index 1391087ae16..3c2369310de 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/util/package-info.java +++ b/key.core/src/main/java/de/uka/ilkd/key/util/package-info.java @@ -4,4 +4,4 @@ @NullMarked package de.uka.ilkd.key.util; -import org.jspecify.annotations.NullMarked; \ No newline at end of file +import org.jspecify.annotations.NullMarked; diff --git a/key.core/src/main/java/de/uka/ilkd/key/util/parsing/BuildingException.java b/key.core/src/main/java/de/uka/ilkd/key/util/parsing/BuildingException.java index 08b2914b9c2..ef6cc9d2b2e 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/util/parsing/BuildingException.java +++ b/key.core/src/main/java/de/uka/ilkd/key/util/parsing/BuildingException.java @@ -5,7 +5,6 @@ import java.net.MalformedURLException; import java.net.URI; -import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.java.Position; import de.uka.ilkd.key.parser.Location; @@ -13,6 +12,7 @@ import org.antlr.v4.runtime.ParserRuleContext; import org.antlr.v4.runtime.Token; +import org.jspecify.annotations.Nullable; /** * @author Alexander Weigl diff --git a/key.core/src/main/java/de/uka/ilkd/key/util/parsing/BuildingIssue.java b/key.core/src/main/java/de/uka/ilkd/key/util/parsing/BuildingIssue.java index 135e72f2367..0f26a96f3a2 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/util/parsing/BuildingIssue.java +++ b/key.core/src/main/java/de/uka/ilkd/key/util/parsing/BuildingIssue.java @@ -3,8 +3,6 @@ * SPDX-License-Identifier: GPL-2.0-only */ package de.uka.ilkd.key.util.parsing; -import org.jspecify.annotations.Nullable; - import de.uka.ilkd.key.java.Position; import org.antlr.v4.runtime.ParserRuleContext; diff --git a/key.core/src/main/java/de/uka/ilkd/key/util/parsing/HasLocation.java b/key.core/src/main/java/de/uka/ilkd/key/util/parsing/HasLocation.java index 33b370cc7ea..a6607e46441 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/util/parsing/HasLocation.java +++ b/key.core/src/main/java/de/uka/ilkd/key/util/parsing/HasLocation.java @@ -4,7 +4,6 @@ package de.uka.ilkd.key.util.parsing; import java.net.MalformedURLException; -import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.parser.Location; diff --git a/key.core/src/main/java/de/uka/ilkd/key/util/parsing/LocatableException.java b/key.core/src/main/java/de/uka/ilkd/key/util/parsing/LocatableException.java index ef430d607e7..ffa7cb32b9b 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/util/parsing/LocatableException.java +++ b/key.core/src/main/java/de/uka/ilkd/key/util/parsing/LocatableException.java @@ -4,10 +4,11 @@ package de.uka.ilkd.key.util.parsing; import java.net.MalformedURLException; -import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.parser.Location; +import org.jspecify.annotations.Nullable; + /** * A simple checked exception which holds an location. * diff --git a/key.core/src/main/java/de/uka/ilkd/key/util/parsing/SyntaxErrorReporter.java b/key.core/src/main/java/de/uka/ilkd/key/util/parsing/SyntaxErrorReporter.java index ae7b6dbd05e..2c584aa6fa8 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/util/parsing/SyntaxErrorReporter.java +++ b/key.core/src/main/java/de/uka/ilkd/key/util/parsing/SyntaxErrorReporter.java @@ -10,7 +10,6 @@ import java.util.List; import java.util.function.Supplier; import java.util.stream.Collectors; -import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.java.Position; import de.uka.ilkd.key.parser.Location; @@ -19,6 +18,7 @@ import org.key_project.util.java.StringUtil; import org.antlr.v4.runtime.*; +import org.jspecify.annotations.Nullable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/key.core/src/main/java/de/uka/ilkd/key/util/pp/Layouter.java b/key.core/src/main/java/de/uka/ilkd/key/util/pp/Layouter.java index 464e4f1b2c9..b7fd8f00528 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/util/pp/Layouter.java +++ b/key.core/src/main/java/de/uka/ilkd/key/util/pp/Layouter.java @@ -4,6 +4,7 @@ package de.uka.ilkd.key.util.pp; import java.util.*; + import org.jspecify.annotations.NonNull; /** diff --git a/key.core/src/test/java/de/uka/ilkd/key/nparser/TestTacletEquality.java b/key.core/src/test/java/de/uka/ilkd/key/nparser/TestTacletEquality.java index 09334f4592b..32c668971a0 100644 --- a/key.core/src/test/java/de/uka/ilkd/key/nparser/TestTacletEquality.java +++ b/key.core/src/test/java/de/uka/ilkd/key/nparser/TestTacletEquality.java @@ -12,7 +12,6 @@ import java.util.Date; import java.util.HashMap; import java.util.stream.Stream; -import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.control.DefaultUserInterfaceControl; import de.uka.ilkd.key.proof.init.InitConfig; @@ -24,6 +23,7 @@ import de.uka.ilkd.key.rule.Taclet; import de.uka.ilkd.key.util.HelperClassForTests; +import org.jspecify.annotations.NonNull; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Assumptions; import org.junit.jupiter.api.BeforeAll; diff --git a/key.core/src/test/java/de/uka/ilkd/key/parser/TestTermParserHeap.java b/key.core/src/test/java/de/uka/ilkd/key/parser/TestTermParserHeap.java index 5a541ea7893..40a1b85091e 100644 --- a/key.core/src/test/java/de/uka/ilkd/key/parser/TestTermParserHeap.java +++ b/key.core/src/test/java/de/uka/ilkd/key/parser/TestTermParserHeap.java @@ -4,11 +4,11 @@ package de.uka.ilkd.key.parser; import java.io.IOException; -import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.logic.Term; import de.uka.ilkd.key.logic.op.Operator; +import org.jspecify.annotations.NonNull; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.slf4j.Logger; diff --git a/key.core/src/test/java/de/uka/ilkd/key/rule/merge/MergeRuleTests.java b/key.core/src/test/java/de/uka/ilkd/key/rule/merge/MergeRuleTests.java index 5d81c3f24fd..925e3658025 100644 --- a/key.core/src/test/java/de/uka/ilkd/key/rule/merge/MergeRuleTests.java +++ b/key.core/src/test/java/de/uka/ilkd/key/rule/merge/MergeRuleTests.java @@ -5,7 +5,6 @@ import java.io.File; import java.util.Iterator; -import org.jspecify.annotations.NonNull; import de.uka.ilkd.key.control.KeYEnvironment; import de.uka.ilkd.key.java.Services; @@ -24,6 +23,7 @@ import de.uka.ilkd.key.util.HelperClassForTests; import de.uka.ilkd.key.util.ProofStarter; +import org.jspecify.annotations.NonNull; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; diff --git a/key.core/src/test/java/de/uka/ilkd/key/smt/newsmt2/MasterHandlerTest.java b/key.core/src/test/java/de/uka/ilkd/key/smt/newsmt2/MasterHandlerTest.java index c2aaf4356b3..56093c90c72 100644 --- a/key.core/src/test/java/de/uka/ilkd/key/smt/newsmt2/MasterHandlerTest.java +++ b/key.core/src/test/java/de/uka/ilkd/key/smt/newsmt2/MasterHandlerTest.java @@ -18,7 +18,6 @@ import java.util.List; import java.util.Properties; import java.util.stream.Collectors; -import org.jspecify.annotations.Nullable; import de.uka.ilkd.key.control.DefaultUserInterfaceControl; import de.uka.ilkd.key.control.KeYEnvironment; @@ -35,6 +34,7 @@ import org.key_project.util.Streams; +import org.jspecify.annotations.Nullable; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Assumptions; import org.junit.jupiter.params.ParameterizedTest; diff --git a/key.util/src/main/java/org/key_project/util/ExtList.java b/key.util/src/main/java/org/key_project/util/ExtList.java index 319cc12386a..b13b4f23cb2 100644 --- a/key.util/src/main/java/org/key_project/util/ExtList.java +++ b/key.util/src/main/java/org/key_project/util/ExtList.java @@ -7,6 +7,7 @@ import java.util.Arrays; import java.util.Iterator; import java.util.LinkedList; + import org.jspecify.annotations.Nullable; /** diff --git a/key.util/src/main/java/org/key_project/util/Strings.java b/key.util/src/main/java/org/key_project/util/Strings.java index a12bcdbf0dd..f30a81a28ac 100644 --- a/key.util/src/main/java/org/key_project/util/Strings.java +++ b/key.util/src/main/java/org/key_project/util/Strings.java @@ -50,7 +50,8 @@ public static boolean isJMLComment(String comment) { * @return the CharSequence in the described format * @param the type of the elements of the iterated collection */ - public static String formatAsList(Iterable it, + public static String formatAsList( + Iterable it, CharSequence open, CharSequence sep, CharSequence close, Function mapper) { return StreamSupport.stream(it.spliterator(), false) diff --git a/key.util/src/main/java/org/key_project/util/collection/IdentityHashSet.java b/key.util/src/main/java/org/key_project/util/collection/IdentityHashSet.java index 315f8da7162..6a58cc47d76 100644 --- a/key.util/src/main/java/org/key_project/util/collection/IdentityHashSet.java +++ b/key.util/src/main/java/org/key_project/util/collection/IdentityHashSet.java @@ -58,13 +58,15 @@ public Iterator iterator() { return innerMap.keySet().iterator(); } - @SuppressWarnings("nullness") // see https://eisop.github.io/cf/manual/manual.html#nullness-collection-toarray + @SuppressWarnings("nullness") // see + // https://eisop.github.io/cf/manual/manual.html#nullness-collection-toarray @Override - public @Nullable Object [] toArray() { + public @Nullable Object[] toArray() { return innerMap.keySet().toArray(); } - @SuppressWarnings("nullness") // see https://eisop.github.io/cf/manual/manual.html#nullness-collection-toarray + @SuppressWarnings("nullness") // see + // https://eisop.github.io/cf/manual/manual.html#nullness-collection-toarray @Override public T1[] toArray(T1[] a) { return innerMap.keySet().toArray(a); diff --git a/recoder/src/test/java/recoder/testsuite/basic/BasicTestsSuite.java b/recoder/src/test/java/recoder/testsuite/basic/BasicTestsSuite.java index d6ccf2f9620..9407df3abb3 100644 --- a/recoder/src/test/java/recoder/testsuite/basic/BasicTestsSuite.java +++ b/recoder/src/test/java/recoder/testsuite/basic/BasicTestsSuite.java @@ -5,8 +5,8 @@ package recoder.testsuite.basic; import java.io.File; -import org.jspecify.annotations.NonNull; +import org.jspecify.annotations.NonNull; import recoder.CrossReferenceServiceConfiguration; import recoder.service.DefaultErrorHandler; From 46b67446f08391d0163a5ceacd4266aa30550ce8 Mon Sep 17 00:00:00 2001 From: Alexander Weigl Date: Mon, 12 Feb 2024 00:24:45 +0100 Subject: [PATCH 29/37] making the switch working correctly --- .github/workflows/code_quality.yml | 16 ++++++++++++++++ build.gradle | 9 +++++---- .../util/collection/DefaultImmutableSet.java | 8 +++++--- settings.gradle | 1 + 4 files changed, 27 insertions(+), 7 deletions(-) diff --git a/.github/workflows/code_quality.yml b/.github/workflows/code_quality.yml index a3bd4d9a1b2..c3aecbc0256 100644 --- a/.github/workflows/code_quality.yml +++ b/.github/workflows/code_quality.yml @@ -9,6 +9,22 @@ on: - 'KeY-*' jobs: + checkerFramework: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Set up JDK 21 + uses: actions/setup-java@v3 + with: + java-version: 21 + distribution: 'corretto' + cache: 'gradle' + - name: Build with Gradle + uses: gradle/gradle-build-action@v2.4.2 + with: + arguments: -DENABLE_NULLNESS=true compileTest + + qodana: runs-on: ubuntu-latest steps: diff --git a/build.gradle b/build.gradle index 7858cbf268d..a25d7aad28f 100644 --- a/build.gradle +++ b/build.gradle @@ -81,10 +81,11 @@ subprojects { //compile group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.12.0' compileOnly 'org.jspecify:jspecify:0.3.0' - compileOnly 'io.github.eisop:checker-qual:3.34.0-eisop1' - compileOnly 'io.github.eisop:checker-util:3.34.0-eisop1' - testCompileOnly 'io.github.eisop:checker-qual:3.34.0-eisop1' - checkerFramework 'io.github.eisop:checker:3.34.0-eisop1' + def eisop_version = "3.42.0-eisop2" + compileOnly "io.github.eisop:checker-qual:$eisop_version" + compileOnly "io.github.eisop:checker-util:$eisop_version" + testCompileOnly "io.github.eisop:checker-qual:$eisop_version" + checkerFramework "io.github.eisop:checker:$eisop_version" testImplementation 'org.junit.jupiter:junit-jupiter-api:5.9.3' testImplementation 'org.junit.jupiter:junit-jupiter-params:5.9.3' diff --git a/key.util/src/main/java/org/key_project/util/collection/DefaultImmutableSet.java b/key.util/src/main/java/org/key_project/util/collection/DefaultImmutableSet.java index 70c0580ae60..ba1af27f3c9 100644 --- a/key.util/src/main/java/org/key_project/util/collection/DefaultImmutableSet.java +++ b/key.util/src/main/java/org/key_project/util/collection/DefaultImmutableSet.java @@ -3,9 +3,7 @@ * SPDX-License-Identifier: GPL-2.0-only */ package org.key_project.util.collection; -import java.util.HashSet; -import java.util.Iterator; -import java.util.Set; +import java.util.*; import java.util.function.Predicate; import java.util.stream.Stream; import java.util.stream.StreamSupport; @@ -64,6 +62,10 @@ private DefaultImmutableSet(ImmutableList elementList) { this.elementList = elementList; } + public static ImmutableSet fromCollection(Collection seq) { + return new DefaultImmutableSet<>(ImmutableList.fromList(seq)); + } + // private static HashSet previousComplains = new HashSet<>(); private void complainAboutSize() { // // Immutable linear sets are very expensive with O(n) addition diff --git a/settings.gradle b/settings.gradle index b6b30a65546..fd11d70f3d6 100644 --- a/settings.gradle +++ b/settings.gradle @@ -16,4 +16,5 @@ include 'keyext.slicing' include 'keyext.caching' // ENABLE NULLNESS here or on the CLI +// This flag is activated to enable the checker framework. // System.setProperty("ENABLE_NULLNESS", "true") \ No newline at end of file From 70bb2aa1b541a2fa152aa6700db4b3b75c3db7ba Mon Sep 17 00:00:00 2001 From: Alexander Weigl Date: Mon, 12 Feb 2024 00:56:05 +0100 Subject: [PATCH 30/37] repair suppres warning --- .../key_project/util/collection/IdentityHashSet.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/key.util/src/main/java/org/key_project/util/collection/IdentityHashSet.java b/key.util/src/main/java/org/key_project/util/collection/IdentityHashSet.java index 6a58cc47d76..9fbcfe44e09 100644 --- a/key.util/src/main/java/org/key_project/util/collection/IdentityHashSet.java +++ b/key.util/src/main/java/org/key_project/util/collection/IdentityHashSet.java @@ -58,17 +58,17 @@ public Iterator iterator() { return innerMap.keySet().iterator(); } - @SuppressWarnings("nullness") // see - // https://eisop.github.io/cf/manual/manual.html#nullness-collection-toarray + // see https://eisop.github.io/cf/manual/manual.html#nullness-collection-toarray + @SuppressWarnings({"nullness","override.return.invalid"}) @Override public @Nullable Object[] toArray() { return innerMap.keySet().toArray(); } - @SuppressWarnings("nullness") // see - // https://eisop.github.io/cf/manual/manual.html#nullness-collection-toarray + // see https://eisop.github.io/cf/manual/manual.html#nullness-collection-toarray + @SuppressWarnings({"nullness","override.return.invalid"}) @Override - public T1[] toArray(T1[] a) { + public T[] toArray(T[] a) { return innerMap.keySet().toArray(a); } From 3c818af5ce30cde04d6a014aa9e987b34d12cdac Mon Sep 17 00:00:00 2001 From: Florian Lanzinger Date: Fri, 26 Apr 2024 17:59:40 +0200 Subject: [PATCH 31/37] Fix merge issues --- .../ilkd/key/nparser/builder/TacletPBuilder.java | 6 +----- .../main/java/de/uka/ilkd/key/smt/RuleAppSMT.java | 2 +- key.ncore/src/main/java/module-info.java | 9 --------- key.util/src/main/java/module-info.java | 15 --------------- 4 files changed, 2 insertions(+), 30 deletions(-) delete mode 100644 key.ncore/src/main/java/module-info.java delete mode 100644 key.util/src/main/java/module-info.java diff --git a/key.core/src/main/java/de/uka/ilkd/key/nparser/builder/TacletPBuilder.java b/key.core/src/main/java/de/uka/ilkd/key/nparser/builder/TacletPBuilder.java index 51702d0a730..a2930cd98cc 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/nparser/builder/TacletPBuilder.java +++ b/key.core/src/main/java/de/uka/ilkd/key/nparser/builder/TacletPBuilder.java @@ -27,11 +27,7 @@ import org.key_project.logic.Name; import org.key_project.logic.sort.Sort; -import org.key_project.util.collection.DefaultImmutableSet; -import org.key_project.util.collection.ImmutableList; -import org.key_project.util.collection.ImmutableSLList; -import org.key_project.util.collection.ImmutableSet; -import org.key_project.util.collection.Pair; +import org.key_project.util.collection.*; import antlr.RecognitionException; import org.antlr.v4.runtime.ParserRuleContext; diff --git a/key.core/src/main/java/de/uka/ilkd/key/smt/RuleAppSMT.java b/key.core/src/main/java/de/uka/ilkd/key/smt/RuleAppSMT.java index d2b58444d59..d5c771c2898 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/smt/RuleAppSMT.java +++ b/key.core/src/main/java/de/uka/ilkd/key/smt/RuleAppSMT.java @@ -4,7 +4,6 @@ package de.uka.ilkd.key.smt; import de.uka.ilkd.key.java.Services; -import de.uka.ilkd.key.logic.Name; import de.uka.ilkd.key.logic.PosInOccurrence; import de.uka.ilkd.key.logic.TermServices; import de.uka.ilkd.key.proof.Goal; @@ -12,6 +11,7 @@ import de.uka.ilkd.key.rule.BuiltInRule; import de.uka.ilkd.key.rule.RuleApp; +import org.key_project.logic.Name; import org.key_project.util.collection.ImmutableList; import org.jspecify.annotations.NonNull; diff --git a/key.ncore/src/main/java/module-info.java b/key.ncore/src/main/java/module-info.java deleted file mode 100644 index 409c7c0a9b9..00000000000 --- a/key.ncore/src/main/java/module-info.java +++ /dev/null @@ -1,9 +0,0 @@ -module org.key_project.ncore { - requires org.key_project.util; - requires org.jspecify; - - /* requires, exports, uses */ - exports org.key_project.logic; - exports org.key_project.logic.op; - exports org.key_project.logic.sort; -} \ No newline at end of file diff --git a/key.util/src/main/java/module-info.java b/key.util/src/main/java/module-info.java deleted file mode 100644 index f48836b67ef..00000000000 --- a/key.util/src/main/java/module-info.java +++ /dev/null @@ -1,15 +0,0 @@ -module org.key_project.util { - requires java.desktop; - requires org.jspecify; - - exports org.key_project.util.bean; - exports org.key_project.util.collection; - exports org.key_project.util.bitops; - exports org.key_project.util.helper; - exports org.key_project.util.java; - exports org.key_project.util.java.thread; - exports org.key_project.util.lookup; - exports org.key_project.util.reflection; - exports org.key_project.util.testcategories; - exports org.key_project.util; -} \ No newline at end of file From 536d9f8bdaaa714957cba9be227f226f5e51c905 Mon Sep 17 00:00:00 2001 From: Alexander Weigl Date: Sat, 27 Apr 2024 13:38:47 +0200 Subject: [PATCH 32/37] jspecify was missing in the compile classpath of tests --- build.gradle | 1 + 1 file changed, 1 insertion(+) diff --git a/build.gradle b/build.gradle index 2ab1c65d884..31395c205f8 100644 --- a/build.gradle +++ b/build.gradle @@ -82,6 +82,7 @@ subprojects { //compile group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.12.0' compileOnly("org.jspecify:jspecify:0.3.0") + testCompileOnly("org.jspecify:jspecify:0.3.0") def eisop_version = "3.42.0-eisop2" compileOnly "io.github.eisop:checker-qual:$eisop_version" compileOnly "io.github.eisop:checker-util:$eisop_version" From 3c6d42206e89e80b6c6e52dccbf02e9ce4658ae5 Mon Sep 17 00:00:00 2001 From: Alexander Weigl Date: Sat, 27 Apr 2024 13:43:50 +0200 Subject: [PATCH 33/37] #equals must allow null values --- .../src/main/java/org/key_project/util/collection/Pair.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/key.util/src/main/java/org/key_project/util/collection/Pair.java b/key.util/src/main/java/org/key_project/util/collection/Pair.java index 56cb9295521..d2bf55fdbff 100644 --- a/key.util/src/main/java/org/key_project/util/collection/Pair.java +++ b/key.util/src/main/java/org/key_project/util/collection/Pair.java @@ -3,6 +3,8 @@ * SPDX-License-Identifier: GPL-2.0-only */ package org.key_project.util.collection; +import org.jspecify.annotations.Nullable; + import java.util.Collection; import java.util.Map; import java.util.Objects; @@ -43,7 +45,7 @@ public String toString() { @Override - public boolean equals(Object o) { + public boolean equals(@Nullable Object o) { if (!(o instanceof Pair p)) { return false; } From 9f44bbf0f5ed3f990ec01b8514dfc3abc6b85f6d Mon Sep 17 00:00:00 2001 From: Florian Lanzinger Date: Tue, 30 Apr 2024 19:14:58 +0200 Subject: [PATCH 34/37] Remove redundant nullness checks and fix test cases --- .../label/FormulaTermLabelRefactoring.java | 2 +- .../util/SymbolicExecutionUtil.java | 2 +- .../java/de/uka/ilkd/key/gui/IssueDialog.java | 6 +- .../key/gui/actions/EditSourceFileAction.java | 4 +- .../key/gui/actions/SendFeedbackAction.java | 5 +- key.util/build.gradle | 5 +- .../util/collection/Immutables.java | 3 +- .../org/key_project/util/java/ArrayUtil.java | 211 ++++++----------- .../key_project/util/java/CollectionUtil.java | 213 +++++++----------- .../util/java/IFilterWithException.java | 4 +- .../org/key_project/util/java/IOUtil.java | 206 ++++++----------- .../org/key_project/util/java/StringUtil.java | 2 +- .../org/key_project/util/java/XMLUtil.java | 123 +++++----- .../util/collection/TestImmutables.java | 23 +- .../collection/TestLeftistHeapOfInteger.java | 1 + .../TestMapAsListFromIntegerToString.java | 3 +- .../collection/TestSLListOfString.java | 10 +- .../util/testcase/java/ArrayUtilTest.java | 116 ++-------- .../testcase/java/CollectionUtilTest.java | 110 ++------- .../util/testcase/java/IOUtilTest.java | 165 ++++---------- .../util/testcase/java/NumberUtilTest.java | 12 - .../util/testcase/java/StringUtilTest.java | 11 +- .../util/testcase/java/XMLUtilTest.java | 11 +- 23 files changed, 393 insertions(+), 855 deletions(-) diff --git a/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/rule/label/FormulaTermLabelRefactoring.java b/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/rule/label/FormulaTermLabelRefactoring.java index 8773f536ec1..f55f6111dcc 100644 --- a/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/rule/label/FormulaTermLabelRefactoring.java +++ b/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/rule/label/FormulaTermLabelRefactoring.java @@ -384,7 +384,7 @@ public static boolean containsSequentFormulasToRefactor(TermLabelState state) { @SuppressWarnings("unchecked") Set sfSet = (Set) labelState.get(SEQUENT_FORMULA_REFACTORING_REQUIRED); - return !CollectionUtil.isEmpty(sfSet); + return sfSet != null && !sfSet.isEmpty(); } /** diff --git a/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/util/SymbolicExecutionUtil.java b/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/util/SymbolicExecutionUtil.java index 0be6244d625..785b03e3d80 100644 --- a/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/util/SymbolicExecutionUtil.java +++ b/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/util/SymbolicExecutionUtil.java @@ -4141,7 +4141,7 @@ public static boolean lazyComputeIsAdditionalBranchVerified(Node node) { Set additinalPredicates = AbstractOperationPO.getAdditionalUninterpretedPredicates(node.proof()); // Check if node can be treated as verified/closed - if (!CollectionUtil.isEmpty(additinalPredicates)) { + if (additinalPredicates != null && !additinalPredicates.isEmpty()) { boolean verified = true; Iterator leafsIter = node.leavesIterator(); while (verified && leafsIter.hasNext()) { diff --git a/key.ui/src/main/java/de/uka/ilkd/key/gui/IssueDialog.java b/key.ui/src/main/java/de/uka/ilkd/key/gui/IssueDialog.java index 6e36b867321..1cdfd42159d 100644 --- a/key.ui/src/main/java/de/uka/ilkd/key/gui/IssueDialog.java +++ b/key.ui/src/main/java/de/uka/ilkd/key/gui/IssueDialog.java @@ -675,7 +675,11 @@ private void updatePreview(PositionedIssueString issue) { String source = StringUtil.replaceNewlines( fileContentsCache.computeIfAbsent(uri, fn -> { try { - return IOUtil.readFrom(finalUri).orElseThrow(); + String result = IOUtil.readFrom(finalUri); + if (result == null) { + throw new NullPointerException(); + } + return result; } catch (IOException e) { LOGGER.debug("Unknown IOException!", e); return "[SOURCE COULD NOT BE LOADED]\n" + e.getMessage(); diff --git a/key.ui/src/main/java/de/uka/ilkd/key/gui/actions/EditSourceFileAction.java b/key.ui/src/main/java/de/uka/ilkd/key/gui/actions/EditSourceFileAction.java index 52e58dcbec8..ad670bf962a 100644 --- a/key.ui/src/main/java/de/uka/ilkd/key/gui/actions/EditSourceFileAction.java +++ b/key.ui/src/main/java/de/uka/ilkd/key/gui/actions/EditSourceFileAction.java @@ -138,10 +138,10 @@ public void addNotify() { } }; Optional file = location.getFileURI(); - String source = IOUtil.readFrom(file.orElse(null)).orElse(""); + String source = IOUtil.readFrom(file.orElse(null)); // workaround for #1641: replace all carriage returns, since JavaDocument can currently // not handle them - source = source.replace("\r", ""); + source = source != null ? source.replace("\r", "") : ""; if (file.isPresent() && file.get().toString().endsWith(".java")) { JavaDocument doc = new JavaDocument(); diff --git a/key.ui/src/main/java/de/uka/ilkd/key/gui/actions/SendFeedbackAction.java b/key.ui/src/main/java/de/uka/ilkd/key/gui/actions/SendFeedbackAction.java index 1d87d1712ac..74fbc397dd9 100644 --- a/key.ui/src/main/java/de/uka/ilkd/key/gui/actions/SendFeedbackAction.java +++ b/key.ui/src/main/java/de/uka/ilkd/key/gui/actions/SendFeedbackAction.java @@ -287,9 +287,8 @@ byte[] retrieveFileData() throws IOException { URI url = ExceptionTools.getLocation(throwable) .flatMap(Location::getFileURI) .orElse(null); - Optional content = IOUtil.readFrom(url); - return content.map(s -> s.getBytes(Charset.defaultCharset())) - .orElse(new byte[0]); + String content = IOUtil.readFrom(url); + return content != null ? content.getBytes(Charset.defaultCharset()) : new byte[0]; } } diff --git a/key.util/build.gradle b/key.util/build.gradle index 507d6826fb8..25700d3ec91 100644 --- a/key.util/build.gradle +++ b/key.util/build.gradle @@ -12,9 +12,10 @@ checkerFramework { extraJavacArgs = [ "-AonlyDefs=^org\\.key_project\\.util", "-Xmaxerrs", "10000", - "-Astubs=$projectDir/src/main/checkerframework", + "-Astubs=$projectDir/src/main/checkerframework:permit-nullness-assertion-exception.astub", + "-AstubNoWarnIfNotFound", "-Werror", "-Aversion", ] } -} \ No newline at end of file +} diff --git a/key.util/src/main/java/org/key_project/util/collection/Immutables.java b/key.util/src/main/java/org/key_project/util/collection/Immutables.java index 893772ceec3..9dc51e9218e 100644 --- a/key.util/src/main/java/org/key_project/util/collection/Immutables.java +++ b/key.util/src/main/java/org/key_project/util/collection/Immutables.java @@ -35,8 +35,7 @@ private Immutables() { * @param list any list, must not be null * @return true iff every */ - public static boolean isDuplicateFree(ImmutableList list) { - + public static boolean isDuplicateFree(ImmutableList list) { HashSet set = new HashSet<>(); for (T element : list) { if (set.contains(element)) { diff --git a/key.util/src/main/java/org/key_project/util/java/ArrayUtil.java b/key.util/src/main/java/org/key_project/util/java/ArrayUtil.java index 86c1d991572..4c17c60ebc0 100644 --- a/key.util/src/main/java/org/key_project/util/java/ArrayUtil.java +++ b/key.util/src/main/java/org/key_project/util/java/ArrayUtil.java @@ -33,14 +33,12 @@ private ArrayUtil() { */ public static @Nullable T search(T[] array, Predicate filter) { T result = null; - if (array != null && filter != null) { - int i = 0; - while (result == null && i < array.length) { - if (filter.test(array[i])) { - result = array[i]; - } - i++; + int i = 0; + while (result == null && i < array.length) { + if (filter.test(array[i])) { + result = array[i]; } + i++; } return result; } @@ -61,33 +59,13 @@ private ArrayUtil() { * @throws IllegalArgumentException Both parameters are {@code null}. */ @SuppressWarnings("unchecked") - public static T[] addAll(T @Nullable [] array, - T @Nullable [] toAdd) { - if (array != null) { - if (toAdd != null) { - T[] result = - (T[]) java.lang.reflect.Array.newInstance(getComponentType(array), + public static T[] addAll(T[] array, T[] toAdd) { + T[] result = + (T[]) java.lang.reflect.Array.newInstance(getComponentType(array), array.length + toAdd.length); - System.arraycopy(array, 0, result, 0, array.length); - System.arraycopy(toAdd, 0, result, array.length, toAdd.length); - return result; - } else { - T[] result = (T[]) java.lang.reflect.Array - .newInstance(getComponentType(array), array.length); - System.arraycopy(array, 0, result, 0, array.length); - return result; - } - } else { - if (toAdd != null) { - T[] result = (T[]) java.lang.reflect.Array - .newInstance(getComponentType(toAdd), toAdd.length); - System.arraycopy(toAdd, 0, result, 0, toAdd.length); - return result; - } else { - throw new IllegalArgumentException( - "Can not create an array if both paramters are null."); - } - } + System.arraycopy(array, 0, result, 0, array.length); + System.arraycopy(toAdd, 0, result, array.length, toAdd.length); + return result; } private static Class getComponentType(T[] array) { @@ -113,29 +91,12 @@ private ArrayUtil() { * @throws IllegalArgumentException Both parameters are {@code null}. */ @SuppressWarnings("unchecked") - public static T[] addAll(T @Nullable [] array, - T @Nullable [] toAdd, Class newArrayType) { - if (array != null) { - if (toAdd != null) { - T[] result = (T[]) java.lang.reflect.Array.newInstance(newArrayType, - array.length + toAdd.length); - System.arraycopy(array, 0, result, 0, array.length); - System.arraycopy(toAdd, 0, result, array.length, toAdd.length); - return result; - } else { - T[] result = (T[]) java.lang.reflect.Array.newInstance(newArrayType, array.length); - System.arraycopy(array, 0, result, 0, array.length); - return result; - } - } else { - if (toAdd != null) { - T[] result = (T[]) java.lang.reflect.Array.newInstance(newArrayType, toAdd.length); - System.arraycopy(toAdd, 0, result, 0, toAdd.length); - return result; - } else { - return (T[]) java.lang.reflect.Array.newInstance(newArrayType, 0); - } - } + public static T[] addAll(T[] array, T[] toAdd, Class newArrayType) { + T[] result = (T[]) java.lang.reflect.Array.newInstance(newArrayType, + array.length + toAdd.length); + System.arraycopy(array, 0, result, 0, array.length); + System.arraycopy(toAdd, 0, result, array.length, toAdd.length); + return result; } /** @@ -154,25 +115,12 @@ private ArrayUtil() { * @throws IllegalArgumentException Both parameters are {@code null}. */ @SuppressWarnings("unchecked") - public static @Nullable T[] add(T @Nullable [] array, - @Nullable T toAdd) { - if (array != null) { - @Nullable - T[] result = (@Nullable T[]) java.lang.reflect.Array - .newInstance(getComponentType(array), array.length + 1); - System.arraycopy(array, 0, result, 0, array.length); - result[array.length] = toAdd; - return result; - } else { - if (toAdd != null) { - T[] result = (T[]) java.lang.reflect.Array.newInstance(toAdd.getClass(), 1); - result[0] = toAdd; - return result; - } else { - throw new IllegalArgumentException( - "Can not create an array if both paramters are null."); - } - } + public static T[] add(T[] array, T toAdd) { + T[] result = (T[]) java.lang.reflect.Array + .newInstance(getComponentType(array), array.length + 1); + System.arraycopy(array, 0, result, 0, array.length); + result[array.length] = toAdd; + return result; } /** @@ -186,14 +134,10 @@ private ArrayUtil() { * @return The new created array with one more element. */ public static int[] add(int[] array, int toAdd) { - if (array != null) { - int[] result = new int[array.length + 1]; - System.arraycopy(array, 0, result, 0, array.length); - result[array.length] = toAdd; - return result; - } else { - return new int[] { toAdd }; - } + int[] result = new int[array.length + 1]; + System.arraycopy(array, 0, result, 0, array.length); + result[array.length] = toAdd; + return result; } /** @@ -208,26 +152,15 @@ public static int[] add(int[] array, int toAdd) { * @return The new created array with one more element. */ @SuppressWarnings("unchecked") - public static T[] insert(T[] array, T toInsert, int index) { - if (array != null) { - T[] result = (T[]) java.lang.reflect.Array - .newInstance(getComponentType(array), array.length + 1); - if (index >= 1) { - System.arraycopy(array, 0, result, 0, index); - } - result[index] = toInsert; - System.arraycopy(array, index, result, index + 1, array.length - index); - return result; - } else { - if (toInsert != null) { - T[] result = (T[]) java.lang.reflect.Array.newInstance(toInsert.getClass(), 1); - result[0] = toInsert; - return result; - } else { - throw new IllegalArgumentException( - "Can not create an array if array and element to insert are null."); - } + public static T[] insert(T[] array, T toInsert, int index) { + T[] result = (T[]) java.lang.reflect.Array + .newInstance(getComponentType(array), array.length + 1); + if (index >= 1) { + System.arraycopy(array, 0, result, 0, index); } + result[index] = toInsert; + System.arraycopy(array, index, result, index + 1, array.length - index); + return result; } /** @@ -239,7 +172,7 @@ public static T[] insert(T[] array, T toInsert, int index) { * @return {@code true} if the array contains the element or {@code false} if not or if the * array is {@code null}. */ - public static boolean contains(T[] array, T toSearch) { + public static boolean contains(T[] array, T toSearch) { return indexOf(array, toSearch) >= 0; } @@ -252,13 +185,11 @@ public static boolean contains(T[] array, T toSearch) { * @return The first index in the array that contains the element to search or {@code -1} if the * elment is not containd in the array. */ - public static int indexOf(T[] array, T toSearch) { + public static int indexOf(T[] array, T toSearch) { int index = -1; - if (array != null) { - for (int i = 0; i < array.length; i++) { - if (Objects.equals(array[i], toSearch)) { - return i; - } + for (int i = 0; i < array.length; i++) { + if (Objects.equals(array[i], toSearch)) { + return i; } } return index; @@ -270,24 +201,18 @@ public static int indexOf(T[] array, T toSearch) { * * @param array The array to remove from. * @param toRemove The element to remove. - * @return A copy of the array without the element toRemove or {@code null} if the given array - * was {@code null}. + * @return A copy of the array without the element toRemove. */ @SuppressWarnings("unchecked") - public static T @Nullable [] remove(T @Nullable [] array, - @Nullable T toRemove) { - if (array != null) { - List result = new LinkedList<>(); - for (T element : array) { - if (!Objects.equals(element, toRemove)) { - result.add(element); - } + public static T[] remove(T[] array, T toRemove) { + List result = new LinkedList<>(); + for (T element : array) { + if (!Objects.equals(element, toRemove)) { + result.add(element); } - return (T[]) result.toArray((T[]) java.lang.reflect.Array - .newInstance(getComponentType(array), result.size())); - } else { - return null; } + return (T[]) result.toArray((T[]) java.lang.reflect.Array + .newInstance(getComponentType(array), result.size())); } /** @@ -296,7 +221,7 @@ public static int indexOf(T[] array, T toSearch) { * @param array The array to convert. * @return The array as {@link String}. */ - public static String toString(T[] array) { + public static String toString(T[] array) { return toString(array, ", "); } @@ -307,18 +232,16 @@ public static String toString(T[] array) { * @param separator The separator between to array elements. * @return The array as {@link String}. */ - public static String toString(T[] array, String separator) { + public static String toString(T[] array, String separator) { StringBuilder sb = new StringBuilder(); - if (array != null) { - boolean afterFirst = false; - for (T element : array) { - if (afterFirst) { - sb.append(separator); - } else { - afterFirst = true; - } - sb.append(element); + boolean afterFirst = false; + for (T element : array) { + if (afterFirst) { + sb.append(separator); + } else { + afterFirst = true; } + sb.append(element); } return sb.toString(); } @@ -342,16 +265,14 @@ public static String toString(int[] array) { */ public static String toString(int[] array, String separator) { StringBuilder sb = new StringBuilder(); - if (array != null) { - boolean afterFirst = false; - for (int element : array) { - if (afterFirst) { - sb.append(separator); - } else { - afterFirst = true; - } - sb.append(element); + boolean afterFirst = false; + for (int element : array) { + if (afterFirst) { + sb.append(separator); + } else { + afterFirst = true; } + sb.append(element); } return sb.toString(); } @@ -362,7 +283,7 @@ public static String toString(int[] array, String separator) { * @param array The array to check. * @return {@code true} array is empty or {@code null}, {@code false} array is not empty. */ - public static boolean isEmpty(T[] array) { - return array == null || array.length == 0; + public static boolean isEmpty(T[] array) { + return array.length == 0; } } diff --git a/key.util/src/main/java/org/key_project/util/java/CollectionUtil.java b/key.util/src/main/java/org/key_project/util/java/CollectionUtil.java index 2baff6d4356..b1872dace0b 100644 --- a/key.util/src/main/java/org/key_project/util/java/CollectionUtil.java +++ b/key.util/src/main/java/org/key_project/util/java/CollectionUtil.java @@ -32,23 +32,19 @@ private CollectionUtil() { * @param toSearch The element to search. * @return The index of the element or {@code -1} if it was not found. */ - public static int indexOf(Iterator iter, T toSearch) { - if (iter != null) { - int i = 0; - boolean found = false; - while (!found && iter.hasNext()) { - T next = iter.next(); - if (Objects.equals(next, toSearch)) { - found = true; - } else { - i++; - } - } - if (found) { - return i; + public static int indexOf(Iterator iter, T toSearch) { + int i = 0; + boolean found = false; + while (!found && iter.hasNext()) { + T next = iter.next(); + if (Objects.equals(next, toSearch)) { + found = true; } else { - return -1; + i++; } + } + if (found) { + return i; } else { return -1; } @@ -74,42 +70,20 @@ public static String toString(Collection collection) { */ public static String toString(Collection collection, String separator) { StringBuilder sb = new StringBuilder(); - if (collection != null) { - boolean afterFirst = false; - for (Object object : collection) { - if (afterFirst) { - if (separator != null) { - sb.append(separator); - } - } else { - afterFirst = true; + boolean afterFirst = false; + for (Object object : collection) { + if (afterFirst) { + if (separator != null) { + sb.append(separator); } - sb.append(object); + } else { + afterFirst = true; } + sb.append(object); } return sb.toString(); } - /** - * Nullpointersave execution of {@link Collection#isEmpty()}. - * - * @param collection The given {@link Collection}. - * @return {@code true} = is empty or {@code null}, {@code false} = is not empty. - */ - public static boolean isEmpty(Collection collection) { - return collection == null || collection.isEmpty(); - } - - /** - * Nullpointersave execution of {@link Map#isEmpty()}. - * - * @param map The given {@link Map}. - * @return {@code true} = is empty or {@code null}, {@code false} = is not empty. - */ - public static boolean isEmpty(Map map) { - return map == null || map.isEmpty(); - } - /** * Adds all elements to the {@link Collection}. * @@ -118,10 +92,8 @@ public static boolean isEmpty(Map map) { * @param iterable The elements to add. */ public static void addAll(Collection collection, Iterable iterable) { - if (collection != null && iterable != null) { - for (T toAdd : iterable) { - collection.add(toAdd); - } + for (T toAdd : iterable) { + collection.add(toAdd); } } @@ -133,20 +105,16 @@ public static void addAll(Collection collection, Iterable iterable) { * @return {@code true} if at least one element was removed, {@code false} if the * {@link Collection} was not modified. */ - public static boolean removeComplete(Collection collection, T toRemove) { - if (collection != null) { - Iterator iter = collection.iterator(); - boolean changed = false; - while (iter.hasNext()) { - if (Objects.equals(iter.next(), toRemove)) { - iter.remove(); - changed = true; - } + public static boolean removeComplete(Collection collection, T toRemove) { + Iterator iter = collection.iterator(); + boolean changed = false; + while (iter.hasNext()) { + if (Objects.equals(iter.next(), toRemove)) { + iter.remove(); + changed = true; } - return changed; - } else { - return false; } + return changed; } /** @@ -156,13 +124,11 @@ public static boolean removeComplete(Collection collection, T toRemove) { * @param filter The {@link IFilter} to use. * @return The elements accepted by the given {@link Predicate}. */ - public static List searchAll(Iterable iterable, Predicate filter) { + public static List searchAll(Iterable iterable, Predicate filter) { List result = new ArrayList<>(); - if (iterable != null && filter != null) { - for (T element : iterable) { - if (filter.test(element)) { - result.add(element); - } + for (T element : iterable) { + if (filter.test(element)) { + result.add(element); } } return result; @@ -175,15 +141,13 @@ public static List searchAll(Iterable iterable, Predicate filter) { * @param filter The filter to select an element. * @return The found element or {@code null} if no element was found. */ - public static @Nullable T search(Iterable iterable, Predicate filter) { + public static @Nullable T search(Iterable iterable, Predicate filter) { T result = null; - if (iterable != null && filter != null) { - Iterator iter = iterable.iterator(); - while (result == null && iter.hasNext()) { - T next = iter.next(); - if (filter.test(next)) { - result = next; - } + Iterator iter = iterable.iterator(); + while (result == null && iter.hasNext()) { + T next = iter.next(); + if (filter.test(next)) { + result = next; } } return result; @@ -197,16 +161,14 @@ public static List searchAll(Iterable iterable, Predicate filter) { * @param filter The filter to select an element. * @return The found element or {@code null} if no element was found. */ - public static @Nullable T searchAndRemove(Iterable iterable, Predicate filter) { + public static @Nullable T searchAndRemove(Iterable iterable, Predicate filter) { T result = null; - if (iterable != null && filter != null) { - Iterator iter = iterable.iterator(); - while (result == null && iter.hasNext()) { - T next = iter.next(); - if (filter.test(next)) { - result = next; - iter.remove(); - } + Iterator iter = iterable.iterator(); + while (result == null && iter.hasNext()) { + T next = iter.next(); + if (filter.test(next)) { + result = next; + iter.remove(); } } return result; @@ -220,18 +182,16 @@ public static List searchAll(Iterable iterable, Predicate filter) { * @param filter The filter to select an element. * @return The found element or {@code null} if no element was found. */ - public static @Nullable T searchAndRemoveWithException( + public static @Nullable T searchAndRemoveWithException( Iterable iterable, IFilterWithException filter) throws E { T result = null; - if (iterable != null && filter != null) { - Iterator iter = iterable.iterator(); - while (result == null && iter.hasNext()) { - T next = iter.next(); - if (filter.select(next)) { - result = next; - iter.remove(); - } + Iterator iter = iterable.iterator(); + while (result == null && iter.hasNext()) { + T next = iter.next(); + if (filter.select(next)) { + result = next; + iter.remove(); } } return result; @@ -244,13 +204,11 @@ public static List searchAll(Iterable iterable, Predicate filter) { * @param element The element to search. * @return {@code true} = contained, {@code false} = not contained */ - public static boolean contains(Iterable iterable, T element) { + public static boolean contains(Iterable iterable, T element) { boolean found = false; - if (iterable != null) { - Iterator iter = iterable.iterator(); - while (!found && iter.hasNext()) { - found = Objects.equals(iter.next(), element); - } + Iterator iter = iterable.iterator(); + while (!found && iter.hasNext()) { + found = Objects.equals(iter.next(), element); } return found; } @@ -263,13 +221,11 @@ public static boolean contains(Iterable iterable, T element) { * @param filter The {@link IFilter} to select elements. * @return The number of elements selected by the {@link IFilter} in the given {@link Iterable}. */ - public static int count(Iterable iterable, Predicate filter) { + public static int count(Iterable iterable, Predicate filter) { int count = 0; - if (iterable != null && filter != null) { - for (T element : iterable) { - if (filter.test(element)) { - count++; - } + for (T element : iterable) { + if (filter.test(element)) { + count++; } } return count; @@ -288,26 +244,21 @@ public static int count(Iterable iterable, Predicate filter) { * @return {@code true} both {@link Collection}s contains same elements, {@code false} * {@link Collection}s are different. */ - public static boolean containsSame(Collection first, Collection second) { - if (first != null) { - if (second != null) { - if (first.size() == second.size()) { - Collection firstCopy = new LinkedList<>(first); - boolean same = true; - Iterator secondIter = second.iterator(); - while (same && secondIter.hasNext()) { - T secondNext = secondIter.next(); - same = firstCopy.remove(secondNext); - } - return same; - } else { - return false; - } - } else { - return first.size() == 0; + @SuppressWarnings("nullness:argument.type.incompatible") + // Checker Framework conservatively disallows passing null to Collection.remove, but if we have a collection of type + // Collection<@Nullable C>, it's probably fine. + public static boolean containsSame(Collection first, Collection second) { + if (first.size() == second.size()) { + Collection firstCopy = new LinkedList<>(first); + boolean same = true; + Iterator secondIter = second.iterator(); + while (same && secondIter.hasNext()) { + T secondNext = secondIter.next(); + same = firstCopy.remove(secondNext); } + return same; } else { - return second == null || second.size() == 0; + return false; } } @@ -317,16 +268,12 @@ public static boolean containsSame(Collection first, Collection second * @param iterable The {@link Iterable} to remove first element from. * @return The removed first element or {@code null} if no element was removed. */ - public static @Nullable T removeFirst(Iterable iterable) { + public static @Nullable T removeFirst(Iterable iterable) { try { - if (iterable != null) { - Iterator iter = iterable.iterator(); - T next = iter.next(); - iter.remove(); - return next; - } else { - return null; - } + Iterator iter = iterable.iterator(); + T next = iter.next(); + iter.remove(); + return next; } catch (NoSuchElementException e) { return null; // Iterable must be empty. } @@ -339,7 +286,7 @@ public static boolean containsSame(Collection first, Collection second * @param toInsert The element to insert. * @param comparator The {@link Comparator} to use. */ - public static void binaryInsert(List list, T toInsert, Comparator comparator) { + public static void binaryInsert(List list, T toInsert, Comparator comparator) { if (list.isEmpty()) { list.add(toInsert); } else { diff --git a/key.util/src/main/java/org/key_project/util/java/IFilterWithException.java b/key.util/src/main/java/org/key_project/util/java/IFilterWithException.java index db96031f16e..5eb8eeb4a92 100644 --- a/key.util/src/main/java/org/key_project/util/java/IFilterWithException.java +++ b/key.util/src/main/java/org/key_project/util/java/IFilterWithException.java @@ -3,13 +3,15 @@ * SPDX-License-Identifier: GPL-2.0-only */ package org.key_project.util.java; +import org.jspecify.annotations.Nullable; + /** * Utility class to select elements which also allows that exceptions are thrown during selection * phase. * * @author Martin Hentschel */ -public interface IFilterWithException { +public interface IFilterWithException { /** * Checks if the given element should be selected. * diff --git a/key.util/src/main/java/org/key_project/util/java/IOUtil.java b/key.util/src/main/java/org/key_project/util/java/IOUtil.java index d7183a789e5..1750224328a 100644 --- a/key.util/src/main/java/org/key_project/util/java/IOUtil.java +++ b/key.util/src/main/java/org/key_project/util/java/IOUtil.java @@ -62,15 +62,11 @@ private IOUtil() { * @param file The file to extract it extension. * @return The file extension or {@code null} if not available. */ - public static @Nullable String getFileExtension(@Nullable File file) { - if (file != null) { - String name = file.getName(); - int dotIndex = name.lastIndexOf('.'); - if (dotIndex >= 0) { - return name.substring(dotIndex + 1); - } else { - return null; - } + public static @Nullable String getFileExtension(File file) { + String name = file.getName(); + int dotIndex = name.lastIndexOf('.'); + if (dotIndex >= 0) { + return name.substring(dotIndex + 1); } else { return null; } @@ -81,18 +77,14 @@ private IOUtil() { * * @param fileName The file name with extension for that the file name without extension is * needed. - * @return The file name without extension or {@code null} if it was not possible to compute it. + * @return The file name without extension. */ - public static @PolyNull String getFileNameWithoutExtension(@PolyNull String fileName) { - if (fileName != null) { - int dotIndex = fileName.lastIndexOf('.'); - if (dotIndex >= 0) { - return fileName.substring(0, dotIndex); - } else { - return fileName; - } + public static String getFileNameWithoutExtension(String fileName) { + int dotIndex = fileName.lastIndexOf('.'); + if (dotIndex >= 0) { + return fileName.substring(0, dotIndex); } else { - return null; + return fileName; } } @@ -102,7 +94,7 @@ private IOUtil() { * @param file The file/folder to delete. */ public static void delete(File file) { - if (file != null && file.exists()) { + if (file.exists()) { if (file.isDirectory()) { File[] children = file.listFiles(); if (children != null) { @@ -122,12 +114,8 @@ public static void delete(File file) { * @return The read content or {@code null} if the {@link URL} is {@code null}. * @throws IOException Occurred Exception. */ - public static Optional readFrom(URL url) throws IOException { - if (url != null) { - return Optional.of(readFrom(url.openStream())); - } else { - return Optional.empty(); - } + public static @Nullable String readFrom(URL url) throws IOException { + return readFrom(url.openStream()); } /** @@ -137,24 +125,19 @@ public static Optional readFrom(URL url) throws IOException { * @return The read content or {@code null} if the {@link URL} is {@code null}. * @throws IOException Occurred Exception. */ - public static Optional readFrom(URI url) throws IOException { - if (url != null) { - return Optional.of(readFrom(url.toURL().openStream())); - } else { - return Optional.empty(); - } + public static @Nullable String readFrom(URI url) throws IOException { + return readFrom(url.toURL().openStream()); } /** * Reads the complete content from the {@link File}. * * @param file The {@link File} to read from. - * @return The read content or {@code null} if the {@link File} is {@code null} or not an - * existing file. + * @return The read content or {@code null} if the {@link File} is not an existing file. * @throws IOException Occurred Exception. */ - public static @Nullable String readFrom(@Nullable File file) throws IOException { - if (file != null && file.isFile()) { + public static @Nullable String readFrom(File file) throws IOException { + if (file.isFile()) { return readFrom(new FileInputStream(file)); } else { return null; @@ -165,14 +148,10 @@ public static Optional readFrom(URI url) throws IOException { * Reads the complete content from the {@link InputStream} and closes it. * * @param in The {@link InputStream} to read from and to close. - * @return The read content or {@code null} if the {@link InputStream} is {@code null}. + * @return The read content. * @throws IOException Occurred Exception. */ - public static @PolyNull String readFrom(@PolyNull InputStream in) throws IOException { - if (in == null) { - return null; - } - + public static String readFrom(InputStream in) throws IOException { try (InputStreamReader reader = new InputStreamReader(in, StandardCharsets.UTF_8)) { StringBuilder sb = new StringBuilder(); char[] buffer = new char[BUFFER_SIZE]; @@ -193,7 +172,7 @@ public static Optional readFrom(URI url) throws IOException { * @throws IOException Occurred Exception. */ public static void writeTo(OutputStream out, String content) throws IOException { - writeTo(out, content, (String) null); + writeTo(out, content, DEFAULT_CHARSET); } /** @@ -206,7 +185,7 @@ public static void writeTo(OutputStream out, String content) throws IOException */ public static void writeTo(OutputStream out, String content, Charset encoding) throws IOException { - writeTo(out, content, encoding != null ? encoding.displayName() : null); + writeTo(out, content, encoding.displayName()); } /** @@ -218,16 +197,9 @@ public static void writeTo(OutputStream out, String content, Charset encoding) * @param encoding The encoding to use. * @throws IOException Occurred Exception. */ - public static void writeTo(@Nullable OutputStream out, @Nullable String content, - @Nullable String encoding) + public static void writeTo(OutputStream out, String content, String encoding) throws IOException { - if (out == null || content == null) { - return; - } - - try (PrintStream printStream = - encoding != null ? new PrintStream(out, false, encoding) - : new PrintStream(out, false, DEFAULT_CHARSET)) { + try (PrintStream printStream = new PrintStream(out, false, encoding)) { printStream.print(content); } } @@ -265,11 +237,7 @@ public static void writeTo(@Nullable OutputStream out, @Nullable String content, * @throws IOException Occurred Exception. */ public static LineInformation[] computeLineInformation(File file) throws IOException { - if (file != null) { - return computeLineInformation(new FileInputStream(file)); - } else { - return computeLineInformation((InputStream) null); - } + return computeLineInformation(new FileInputStream(file)); } /** @@ -304,12 +272,8 @@ public static LineInformation[] computeLineInformation(File file) throws IOExcep * @return The computed start indices. * @throws IOException Occurred Exception. */ - public static LineInformation[] computeLineInformation(@Nullable InputStream in) + public static LineInformation[] computeLineInformation(InputStream in) throws IOException { - if (in == null) { - return new LineInformation[0]; - } - try (InputStreamReader reader = new InputStreamReader(in, StandardCharsets.UTF_8)) { List result = new LinkedList<>(); char[] buffer = new char[BUFFER_SIZE]; // Buffer with the read signs @@ -547,13 +511,11 @@ public static File createTempDirectory(String prefix, String suffix) throws IOEx */ public static List search(File file, final Predicate filter) throws IOException { final List result = new LinkedList<>(); - if (file != null) { - visit(file, visitedFile -> { - if (filter == null || filter.test(visitedFile)) { - result.add(visitedFile); - } - }); - } + visit(file, visitedFile -> { + if (filter == null || filter.test(visitedFile)) { + result.add(visitedFile); + } + }); return result; } @@ -565,13 +527,11 @@ public static List search(File file, final Predicate filter) throws * @throws IOException Occurred Exception */ public static void visit(File file, IFileVisitor visitor) throws IOException { - if (file != null && visitor != null) { - visitor.visit(file); - File[] children = file.listFiles(); - if (children != null) { - for (File child : children) { - visit(child, visitor); - } + visitor.visit(file); + File[] children = file.listFiles(); + if (children != null) { + for (File child : children) { + visit(child, visitor); } } } @@ -598,16 +558,12 @@ public interface IFileVisitor { * @return A new {@link InputStream} with with the replaced line breaks. * @throws IOException Occurred Exception. */ - public static @PolyNull InputStream unifyLineBreaks(@PolyNull InputStream in) + public static InputStream unifyLineBreaks(InputStream in) throws IOException { - if (in != null) { - String text = IOUtil.readFrom(in); - text = text.replace("\r\n", "\n"); - text = text.replace("\r", "\n"); - return new ByteArrayInputStream(text.getBytes(StandardCharsets.UTF_8)); - } else { - return null; - } + String text = IOUtil.readFrom(in); + text = text.replace("\r\n", "\n"); + text = text.replace("\r", "\n"); + return new ByteArrayInputStream(text.getBytes(StandardCharsets.UTF_8)); } /** @@ -637,15 +593,14 @@ public static boolean contains(Iterable parents, File child) { * @return {@code true} child is contained (recursive) in parent, {@code false} child is not * contained in parent. */ - public static boolean contains(@Nullable File parent, @Nullable File child) { + public static boolean contains(File parent, File child) { boolean contains = false; - if (parent != null && child != null) { - while (!contains && child != null) { - if (parent.equals(child)) { - contains = true; - } - child = child.getParentFile(); + @Nullable File current = child; + while (!contains && current != null) { + if (parent.equals(current)) { + contains = true; } + current = current.getParentFile(); } return contains; } @@ -660,25 +615,16 @@ public static boolean contains(@Nullable File parent, @Nullable File child) { */ public static boolean copy(Reader source, StringWriter target) throws IOException { try { - if (source != null && target != null) { - char[] buffer = new char[BUFFER_SIZE]; - int read; - while ((read = source.read(buffer)) >= 1) { - target.write(buffer, 0, read); - } - return true; - } else { - return false; + char[] buffer = new char[BUFFER_SIZE]; + int read; + while ((read = source.read(buffer)) >= 1) { + target.write(buffer, 0, read); } + return true; } finally { - if (source != null) { - source.close(); - } - if (target != null) { - target.close(); - } + source.close(); + target.close(); } - } /** @@ -692,47 +638,25 @@ public static boolean copy(Reader source, StringWriter target) throws IOExceptio */ public static boolean copy(InputStream source, OutputStream target) throws IOException { try { - if (source != null && target != null) { - byte[] buffer = new byte[BUFFER_SIZE]; - int read; - while ((read = source.read(buffer)) >= 1) { - target.write(buffer, 0, read); - } - return true; - } else { - return false; + byte[] buffer = new byte[BUFFER_SIZE]; + int read; + while ((read = source.read(buffer)) >= 1) { + target.write(buffer, 0, read); } + return true; } finally { - if (source != null) { - source.close(); - } - if (target != null) { - target.close(); - } + source.close(); + target.close(); } } - /** - * Checks if the given {@link File} exists. - * - * @param file The {@link File} to check. - * @return {@code true} {@link File} is not {@code null} and exists, {@code false} otherwise. - */ - public static boolean exists(File file) { - return file != null && file.exists(); - } - public static @Nullable URL getClassLocationURL(Class classInstance) { CodeSource cs = classInstance.getProtectionDomain().getCodeSource(); return cs != null ? cs.getLocation() : null; } - public static @Nullable File getClassLocation(@Nullable Class classInstance) { - if (classInstance == null) { - return null; - } else { - return toFile(getClassLocationURL(classInstance)); - } + public static @Nullable File getClassLocation(Class classInstance) { + return toFile(getClassLocationURL(classInstance)); } public static @Nullable File getProjectRoot(Class classInstance) { @@ -803,7 +727,7 @@ public static File getTempDirectory() { * @param name The segment to validate. * @return The validated OS independent path segment in which each invalid sign is replaced. */ - public static @PolyNull String validateOSIndependentFileName(@PolyNull String name) { + public static String validateOSIndependentFileName(String name) { if (name != null) { char[] latinBig = StringUtil.LATIN_ALPHABET_BIG.toCharArray(); char[] latinSmall = StringUtil.LATIN_ALPHABET_SMALL.toCharArray(); diff --git a/key.util/src/main/java/org/key_project/util/java/StringUtil.java b/key.util/src/main/java/org/key_project/util/java/StringUtil.java index f169839fc7e..710c322e5d6 100644 --- a/key.util/src/main/java/org/key_project/util/java/StringUtil.java +++ b/key.util/src/main/java/org/key_project/util/java/StringUtil.java @@ -123,7 +123,7 @@ public static boolean isTrimmedEmpty(@Nullable String text) { * * @return The created {@link Comparator}. */ - public static Comparator createIgnoreCaseComparator() { + public static Comparator<@Nullable String> createIgnoreCaseComparator() { return (o1, o2) -> { if (o1 != null && o2 != null) { return o1.compareToIgnoreCase(o2); diff --git a/key.util/src/main/java/org/key_project/util/java/XMLUtil.java b/key.util/src/main/java/org/key_project/util/java/XMLUtil.java index 1489e288196..0a3b5022dec 100644 --- a/key.util/src/main/java/org/key_project/util/java/XMLUtil.java +++ b/key.util/src/main/java/org/key_project/util/java/XMLUtil.java @@ -37,42 +37,37 @@ private XMLUtil() { * @param replacer The {@link ITagReplacer} to use. * @return The new created text. */ - public static @Nullable String replaceTags(@Nullable String text, - @Nullable ITagReplacer replacer) { - if (text != null && replacer != null) { - StringBuilder sb = new StringBuilder(); - char[] signs = text.toCharArray(); - boolean inTag = false; - boolean inAttribute = false; - StringBuilder tagSB = null; - for (char sign : signs) { - if (!inTag) { - if (sign == '<') { - inTag = true; - tagSB = new StringBuilder(); - tagSB.append(sign); - } else { - sb.append(sign); - } - } else { - assert tagSB != null - : "@AssumeAssertion(nullness): tagSB must have been intialised already"; + public static String replaceTags(String text, ITagReplacer replacer) { + StringBuilder sb = new StringBuilder(); + char[] signs = text.toCharArray(); + boolean inTag = false; + boolean inAttribute = false; + StringBuilder tagSB = null; + for (char sign : signs) { + if (!inTag) { + if (sign == '<') { + inTag = true; + tagSB = new StringBuilder(); tagSB.append(sign); - if (sign == '>' && !inAttribute) { - inTag = false; - String replacement = replacer.replaceTag(tagSB.toString()); - if (replacement != null) { - sb.append(replacement); - } - } else if (sign == '\'' || sign == '"') { - inAttribute = !inAttribute; + } else { + sb.append(sign); + } + } else { + assert tagSB != null + : "@AssumeAssertion(nullness): tagSB must have been intialised already"; + tagSB.append(sign); + if (sign == '>' && !inAttribute) { + inTag = false; + String replacement = replacer.replaceTag(tagSB.toString()); + if (replacement != null) { + sb.append(replacement); } + } else if (sign == '\'' || sign == '"') { + inAttribute = !inAttribute; } } - return sb.toString(); - } else { - return null; } + return sb.toString(); } /** @@ -126,31 +121,27 @@ public static class HTMLRendererReplacer implements ITagReplacer { * @param text The text to remove tags from. * @return The text without tags. */ - public static @Nullable String removeTags(@Nullable String text) { - if (text != null) { - StringBuilder sb = new StringBuilder(); - char[] signs = text.toCharArray(); - boolean inTag = false; - boolean inAttribute = false; - for (char sign : signs) { - if (!inTag) { - if (sign == '<') { - inTag = true; - } else { - sb.append(sign); - } + public static String removeTags(String text) { + StringBuilder sb = new StringBuilder(); + char[] signs = text.toCharArray(); + boolean inTag = false; + boolean inAttribute = false; + for (char sign : signs) { + if (!inTag) { + if (sign == '<') { + inTag = true; } else { - if (sign == '>' && !inAttribute) { - inTag = false; - } else if (sign == '\'' || sign == '"') { - inAttribute = !inAttribute; - } + sb.append(sign); + } + } else { + if (sign == '>' && !inAttribute) { + inTag = false; + } else if (sign == '\'' || sign == '"') { + inAttribute = !inAttribute; } } - return sb.toString(); - } else { - return null; } + return sb.toString(); } /** @@ -175,24 +166,20 @@ public static class HTMLRendererReplacer implements ITagReplacer { * @param text The text to encode. * @return The encoded text. */ - public static @Nullable String encodeText(@Nullable String text) { - if (text != null) { - char[] signs = text.toCharArray(); - StringBuilder sb = new StringBuilder(); - for (char sign : signs) { - switch (sign) { - case '"' -> sb.append("""); - case '&' -> sb.append("&"); - case '\'' -> sb.append("'"); - case '<' -> sb.append("<"); - case '>' -> sb.append(">"); - default -> sb.append(sign); - } + public static String encodeText(String text) { + char[] signs = text.toCharArray(); + StringBuilder sb = new StringBuilder(); + for (char sign : signs) { + switch (sign) { + case '"' -> sb.append("""); + case '&' -> sb.append("&"); + case '\'' -> sb.append("'"); + case '<' -> sb.append("<"); + case '>' -> sb.append(">"); + default -> sb.append(sign); } - return sb.toString(); - } else { - return null; } + return sb.toString(); } /** diff --git a/key.util/src/test/java/org/key_project/util/collection/TestImmutables.java b/key.util/src/test/java/org/key_project/util/collection/TestImmutables.java index 24ad263cdcd..c0a2283e633 100644 --- a/key.util/src/test/java/org/key_project/util/collection/TestImmutables.java +++ b/key.util/src/test/java/org/key_project/util/collection/TestImmutables.java @@ -3,6 +3,7 @@ * SPDX-License-Identifier: GPL-2.0-only */ package org.key_project.util.collection; +import org.jspecify.annotations.Nullable; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.*; @@ -34,17 +35,17 @@ public void testRemoveDuplicatesLarge() { @Test public void testRemoveDuplicates() { - String[][] a = { { "a", "b", "a", "c", "d", "d", "a", "e" }, { null, "a", null }, + @Nullable String[][] a = { { "a", "b", "a", "c", "d", "d", "a", "e" }, { null, "a", null }, { "1", "1", "1", "1", "1" } }; - String[][] expected = { { "a", "b", "c", "d", "e" }, { null, "a" }, { "1" } }; + @Nullable String[][] expected = { { "a", "b", "c", "d", "e" }, { null, "a" }, { "1" } }; for (int i = 0; i < a.length; i++) { - ImmutableList l = ImmutableSLList.nil().prepend(a[i]).reverse(); + ImmutableList<@Nullable String> l = ImmutableSLList.<@Nullable String>nil().prepend(a[i]).reverse(); assertFalse(Immutables.isDuplicateFree(l)); - ImmutableList cleaned = Immutables.removeDuplicates(l); + ImmutableList<@Nullable String> cleaned = Immutables.removeDuplicates(l); String[] a2 = cleaned.reverse().toArray(String.class); @@ -65,25 +66,25 @@ public void testRemoveDuplicatesIdentical() { @Test public void testIsDuplicateFree() { - String[][] a = { { "a", "b", "c", "d", "e" }, {}, { "a" }, { null }, { null, "a" } }; + @Nullable String[][] a = { { "a", "b", "c", "d", "e" }, {}, { "a" }, { null }, { null, "a" } }; - for (String[] strings : a) { - ImmutableList l = ImmutableSLList.nil().prepend(strings); + for (@Nullable String[] strings : a) { + ImmutableList<@Nullable String> l = ImmutableSLList.<@Nullable String>nil().prepend(strings); assertTrue(Immutables.isDuplicateFree(l)); } - String[][] b = { { "a", "a" }, { "a", "b", "c", "d", "a" }, { "a", "b", "a", "d", "e" }, + @Nullable String[][] b = { { "a", "a" }, { "a", "b", "c", "d", "a" }, { "a", "b", "a", "d", "e" }, { "a", "b", "d", "d", "e" }, { "a", "b", "c", "d", "d" }, { null, "a", null } }; - for (String[] strings : b) { - ImmutableList l = ImmutableSLList.nil().prepend(strings); + for (@Nullable String[] strings : b) { + ImmutableList<@Nullable String> l = ImmutableSLList.<@Nullable String>nil().prepend(strings); assertFalse(Immutables.isDuplicateFree(l)); } } - private static void assertDeepEquals(Object[] expected, Object[] array) { + private static void assertDeepEquals(@Nullable Object[] expected, @Nullable Object[] array) { assertEquals(expected.length, array.length); for (int i = 0; i < array.length; i++) { assertEquals(expected[i], array[i]); diff --git a/key.util/src/test/java/org/key_project/util/testcase/collection/TestLeftistHeapOfInteger.java b/key.util/src/test/java/org/key_project/util/testcase/collection/TestLeftistHeapOfInteger.java index 3058ad1c094..bb5a03f8942 100644 --- a/key.util/src/test/java/org/key_project/util/testcase/collection/TestLeftistHeapOfInteger.java +++ b/key.util/src/test/java/org/key_project/util/testcase/collection/TestLeftistHeapOfInteger.java @@ -19,6 +19,7 @@ import static org.junit.jupiter.api.Assertions.assertSame; import static org.junit.jupiter.api.Assertions.assertTrue; +@SuppressWarnings("initialization") public class TestLeftistHeapOfInteger { ImmutableList a; diff --git a/key.util/src/test/java/org/key_project/util/testcase/collection/TestMapAsListFromIntegerToString.java b/key.util/src/test/java/org/key_project/util/testcase/collection/TestMapAsListFromIntegerToString.java index 61c7f52c134..7d492d19e3a 100644 --- a/key.util/src/test/java/org/key_project/util/testcase/collection/TestMapAsListFromIntegerToString.java +++ b/key.util/src/test/java/org/key_project/util/testcase/collection/TestMapAsListFromIntegerToString.java @@ -14,8 +14,7 @@ /** * JUnit test for MapAsList implementation */ - - +@SuppressWarnings("initialization") public class TestMapAsListFromIntegerToString { private String[] entryStr; diff --git a/key.util/src/test/java/org/key_project/util/testcase/collection/TestSLListOfString.java b/key.util/src/test/java/org/key_project/util/testcase/collection/TestSLListOfString.java index 90af33bf6fe..12838a8b85a 100644 --- a/key.util/src/test/java/org/key_project/util/testcase/collection/TestSLListOfString.java +++ b/key.util/src/test/java/org/key_project/util/testcase/collection/TestSLListOfString.java @@ -6,6 +6,7 @@ import java.util.Iterator; import java.util.Objects; +import org.jspecify.annotations.Nullable; import org.key_project.util.collection.ImmutableList; import org.key_project.util.collection.ImmutableSLList; @@ -19,6 +20,7 @@ /** * tests non-destructive list implementation with String */ +@SuppressWarnings("initialization") public class TestSLListOfString { private static final Logger LOGGER = LoggerFactory.getLogger(TestSLListOfString.class); @@ -29,8 +31,8 @@ public class TestSLListOfString { ImmutableList b; // "A" "B" ImmutableList c; // "A" "B" "C" "D" ImmutableList d; // "A" "B" "A" - ImmutableList e; // "A" "B" null - ImmutableList e1; // "A" "B" null + ImmutableList<@Nullable String> e; // "A" "B" null + ImmutableList<@Nullable String> e1; // "A" "B" null @BeforeEach @@ -40,8 +42,8 @@ public void setUp() { b = ImmutableSLList.nil().prepend("B").prepend("A"); c = ImmutableSLList.nil().prepend("D").prepend("C").prepend("B").prepend("A"); d = ImmutableSLList.nil().prepend("A").prepend("B").prepend("A"); - e = ImmutableSLList.nil().prepend((String) null).prepend("B").prepend("A"); - e1 = ImmutableSLList.nil().prepend((String) null).prepend("B").prepend("A"); + e = ImmutableSLList.<@Nullable String>nil().prepend((String) null).prepend("B").prepend("A"); + e1 = ImmutableSLList.<@Nullable String>nil().prepend((String) null).prepend("B").prepend("A"); } // tests prepend and implicitly iterator, size diff --git a/key.util/src/test/java/org/key_project/util/testcase/java/ArrayUtilTest.java b/key.util/src/test/java/org/key_project/util/testcase/java/ArrayUtilTest.java index 6a80dd23658..51c1d094e05 100644 --- a/key.util/src/test/java/org/key_project/util/testcase/java/ArrayUtilTest.java +++ b/key.util/src/test/java/org/key_project/util/testcase/java/ArrayUtilTest.java @@ -5,6 +5,7 @@ import java.util.function.Predicate; +import org.jspecify.annotations.Nullable; import org.key_project.util.java.ArrayUtil; import org.key_project.util.java.StringUtil; @@ -20,24 +21,14 @@ public class ArrayUtilTest { @Test public void testInsert() { - String[] array = { "A", "B", "C" }; + @Nullable String[] array = { "A", "B", "C" }; // Test possible indices assertArray(ArrayUtil.insert(array, "X", 0), "X", "A", "B", "C"); assertArray(ArrayUtil.insert(array, "X", 1), "A", "X", "B", "C"); assertArray(ArrayUtil.insert(array, "X", 2), "A", "B", "X", "C"); assertArray(ArrayUtil.insert(array, "X", 3), "A", "B", "C", "X"); - // Test null array - assertArray(ArrayUtil.insert(null, "X", 0), "X"); // Test null element assertArray(ArrayUtil.insert(array, null, 1), "A", null, "B", "C"); - // Test null array an delement - try { - ArrayUtil.insert(null, null, 0); - fail(); - } catch (IllegalArgumentException e) { - assertEquals("Can not create an array if array and element to insert are null.", - e.getMessage()); - } // Test invalid indices try { ArrayUtil.insert(array, "X", -1); @@ -52,7 +43,7 @@ public void testInsert() { } @SuppressWarnings("unchecked") - private void assertArray(T[] current, T... expected) { + private void assertArray(T[] current, T... expected) { assertNotNull(current); assertEquals(current.length, expected.length); for (int i = 0; i < current.length; i++) { @@ -65,14 +56,12 @@ private void assertArray(T[] current, T... expected) { */ @Test public void testSearch() { - String[] array = { "A", "B", "C", "D" }; - assertEquals("A", ArrayUtil.search(array, "A"::equals)); - assertEquals("B", ArrayUtil.search(array, "B"::equals)); - assertEquals("C", ArrayUtil.search(array, "C"::equals)); - assertEquals("D", ArrayUtil.search(array, "D"::equals)); - assertNull(ArrayUtil.search(array, "E"::equals)); - assertNull(ArrayUtil.search(array, null)); - assertNull(ArrayUtil.search(null, "E"::equals)); + @Nullable String[] array = { "A", "B", "C", "D" }; + assertEquals("A", ArrayUtil.<@Nullable String>search(array, "A"::equals)); + assertEquals("B", ArrayUtil.<@Nullable String>search(array, "B"::equals)); + assertEquals("C", ArrayUtil.<@Nullable String>search(array, "C"::equals)); + assertEquals("D", ArrayUtil.<@Nullable String>search(array, "D"::equals)); + assertNull(ArrayUtil.<@Nullable String>search(array, "E"::equals)); } /** @@ -80,7 +69,6 @@ public void testSearch() { */ @Test public void testIsEmpty() { - assertTrue(ArrayUtil.isEmpty(null)); assertTrue(ArrayUtil.isEmpty(new String[] {})); assertFalse(ArrayUtil.isEmpty(new String[] { "A" })); assertFalse(ArrayUtil.isEmpty(new String[] { null })); @@ -92,12 +80,10 @@ public void testIsEmpty() { */ @Test public void testToString_int_String() { - assertEquals(StringUtil.EMPTY_STRING, ArrayUtil.toString((int[]) null, ";")); assertEquals(StringUtil.EMPTY_STRING, ArrayUtil.toString(new int[] {}, ";")); assertEquals("1", ArrayUtil.toString(new int[] { 1 }, ";")); assertEquals("1;2", ArrayUtil.toString(new int[] { 1, 2 }, ";")); assertEquals("1;2;3", ArrayUtil.toString(new int[] { 1, 2, 3 }, ";")); - assertEquals("1null2null3", ArrayUtil.toString(new int[] { 1, 2, 3 }, null)); } /** @@ -105,7 +91,6 @@ public void testToString_int_String() { */ @Test public void testToString_int() { - assertEquals(StringUtil.EMPTY_STRING, ArrayUtil.toString((int[]) null)); assertEquals(StringUtil.EMPTY_STRING, ArrayUtil.toString(new int[] {})); assertEquals("1", ArrayUtil.toString(new int[] { 1 })); assertEquals("1, 2", ArrayUtil.toString(new int[] { 1, 2 })); @@ -117,14 +102,11 @@ public void testToString_int() { */ @Test public void testToString_Object_String() { - assertEquals(StringUtil.EMPTY_STRING, ArrayUtil.toString((String[]) null, ";")); assertEquals(StringUtil.EMPTY_STRING, ArrayUtil.toString(new String[] {}, ";")); assertEquals("A", ArrayUtil.toString(new String[] { "A" }, ";")); assertEquals("A;B", ArrayUtil.toString(new String[] { "A", "B" }, ";")); assertEquals("A;B;null", ArrayUtil.toString(new String[] { "A", "B", null }, ";")); assertEquals("A;B;null;D", ArrayUtil.toString(new String[] { "A", "B", null, "D" }, ";")); - assertEquals("AnullBnullnullnullD", - ArrayUtil.toString(new String[] { "A", "B", null, "D" }, null)); } /** @@ -132,7 +114,6 @@ public void testToString_Object_String() { */ @Test public void testToString_Object() { - assertEquals(StringUtil.EMPTY_STRING, ArrayUtil.toString((String[]) null)); assertEquals(StringUtil.EMPTY_STRING, ArrayUtil.toString(new String[] {})); assertEquals("A", ArrayUtil.toString(new String[] { "A" })); assertEquals("A, B", ArrayUtil.toString(new String[] { "A", "B" })); @@ -146,7 +127,7 @@ public void testToString_Object() { @Test public void testRemove() { // Test remove on array - String[] array = new String[] { "A", "B", "C", null, "D", null, null, "C", "A" }; + @Nullable String[] array = new @Nullable String[] { "A", "B", "C", null, "D", null, null, "C", "A" }; array = ArrayUtil.remove(array, "B"); // Remove B assertArrayEquals(array, "A", "C", null, "D", null, null, "C", "A"); array = ArrayUtil.remove(array, "B"); // Remove B again @@ -163,9 +144,6 @@ public void testRemove() { assertArrayEquals(array); array = ArrayUtil.remove(array, "A"); // Remove A assertArrayEquals(array); - // Test null array - array = ArrayUtil.remove(null, "X"); - assertNull(array); } /** @@ -190,32 +168,13 @@ protected void assertArrayEquals(T[] array, T... expectedValues) { public void testAddAll() { String[] first = new String[] { "A", "B", "C" }; String[] second = new String[] { "D", "E" }; - // Test first parameter null - String[] combined = ArrayUtil.addAll(null, second); - assertEquals(2, combined.length); - assertEquals("D", combined[0]); - assertEquals("E", combined[1]); - // Test second parameter null - combined = ArrayUtil.addAll(first, null); - assertEquals(3, combined.length); - assertEquals("A", combined[0]); - assertEquals("B", combined[1]); - assertEquals("C", combined[2]); - // Test both parameter valid - combined = ArrayUtil.addAll(first, second); + @Nullable String[] combined = ArrayUtil.addAll(first, second); assertEquals(5, combined.length); assertEquals("A", combined[0]); assertEquals("B", combined[1]); assertEquals("C", combined[2]); assertEquals("D", combined[3]); assertEquals("E", combined[4]); - // Test both parameter null - try { - ArrayUtil.addAll(null, null); - fail("Exception expected if both parameters are null."); - } catch (IllegalArgumentException e) { - assertEquals("Can not create an array if both paramters are null.", e.getMessage()); - } } /** @@ -225,21 +184,7 @@ public void testAddAll() { public void testAddAll_newType() { String[] first = new String[] { "A", "B", "C" }; String[] second = new String[] { "D", "E" }; - // Test first parameter null - Object[] combined = ArrayUtil.addAll(null, second, Object.class); - assertEquals(Object.class, combined.getClass().getComponentType()); - assertEquals(2, combined.length); - assertEquals("D", combined[0]); - assertEquals("E", combined[1]); - // Test second parameter null - combined = ArrayUtil.addAll(first, null, Object.class); - assertEquals(Object.class, combined.getClass().getComponentType()); - assertEquals(3, combined.length); - assertEquals("A", combined[0]); - assertEquals("B", combined[1]); - assertEquals("C", combined[2]); - // Test both parameter valid - combined = ArrayUtil.addAll(first, second, Object.class); + @Nullable Object[] combined = ArrayUtil.addAll(first, second, Object.class); assertEquals(Object.class, combined.getClass().getComponentType()); assertEquals(5, combined.length); assertEquals("A", combined[0]); @@ -247,10 +192,6 @@ public void testAddAll_newType() { assertEquals("C", combined[2]); assertEquals("D", combined[3]); assertEquals("E", combined[4]); - // Test both parameter null - combined = ArrayUtil.addAll(null, null, Object.class); - assertEquals(Object.class, combined.getClass().getComponentType()); - assertEquals(0, combined.length); } /** @@ -258,14 +199,9 @@ public void testAddAll_newType() { */ @Test public void testAdd_int() { - // Test null array - int[] result = ArrayUtil.add(null, 1); - assertNotNull(result); - assertEquals(1, result.length); - assertEquals(1, result[0]); // Test empty array int[] array = new int[] {}; - result = ArrayUtil.add(array, 1); + int[] result = ArrayUtil.add(array, 1); assertNotNull(result); assertEquals(1, result.length); assertEquals(1, result[0]); @@ -300,14 +236,9 @@ public void testAdd_int() { */ @Test public void testAdd_Object() { - // Test null array - String[] result = ArrayUtil.add(null, "A"); - assertNotNull(result); - assertEquals(1, result.length); - assertEquals("A", result[0]); // Test empty array - String[] array = new String[] {}; - result = ArrayUtil.add(array, "A"); + @Nullable String[] array = new String[] {}; + @Nullable String[] result = ArrayUtil.add(array, "A"); assertNotNull(result); assertEquals(1, result.length); assertEquals("A", result[0]); @@ -344,13 +275,6 @@ public void testAdd_Object() { assertEquals("B", result[1]); assertEquals("C", result[2]); assertNull(result[3]); - // Test null new element on null array - try { - ArrayUtil.add(null, null); - fail("Exception expected if both parameters are null."); - } catch (IllegalArgumentException e) { - assertEquals("Can not create an array if both paramters are null.", e.getMessage()); - } } /** @@ -360,14 +284,12 @@ public void testAdd_Object() { public void testContains() { String[] array = { "A", "B", "C" }; assertFalse(ArrayUtil.contains(array, null)); - assertFalse(ArrayUtil.contains(null, "A")); assertTrue(ArrayUtil.contains(array, "A")); assertTrue(ArrayUtil.contains(array, "B")); assertTrue(ArrayUtil.contains(array, "C")); assertFalse(ArrayUtil.contains(array, "D")); - String[] arrayWithNull = { "A", "B", null, "D" }; + @Nullable String[] arrayWithNull = { "A", "B", null, "D" }; assertTrue(ArrayUtil.contains(arrayWithNull, null)); - assertFalse(ArrayUtil.contains(null, "A")); assertTrue(ArrayUtil.contains(arrayWithNull, "A")); assertTrue(ArrayUtil.contains(arrayWithNull, "B")); assertFalse(ArrayUtil.contains(arrayWithNull, "C")); @@ -375,7 +297,6 @@ public void testContains() { assertFalse(ArrayUtil.contains(arrayWithNull, "E")); String[] arrayWithDoubleElements = { "B", "A", "C", "B", "C" }; assertFalse(ArrayUtil.contains(arrayWithDoubleElements, null)); - assertFalse(ArrayUtil.contains(null, "A")); assertTrue(ArrayUtil.contains(arrayWithDoubleElements, "A")); assertTrue(ArrayUtil.contains(arrayWithDoubleElements, "B")); assertTrue(ArrayUtil.contains(arrayWithDoubleElements, "C")); @@ -389,14 +310,12 @@ public void testContains() { public void testIndexOf() { String[] array = { "A", "B", "C" }; assertEquals(-1, ArrayUtil.indexOf(array, null)); - assertEquals(-1, ArrayUtil.indexOf(null, "A")); assertEquals(0, ArrayUtil.indexOf(array, "A")); assertEquals(1, ArrayUtil.indexOf(array, "B")); assertEquals(2, ArrayUtil.indexOf(array, "C")); assertEquals(-1, ArrayUtil.indexOf(array, "D")); - String[] arrayWithNull = { "A", "B", null, "D" }; + @Nullable String[] arrayWithNull = { "A", "B", null, "D" }; assertEquals(2, ArrayUtil.indexOf(arrayWithNull, null)); - assertEquals(-1, ArrayUtil.indexOf(null, "A")); assertEquals(0, ArrayUtil.indexOf(arrayWithNull, "A")); assertEquals(1, ArrayUtil.indexOf(arrayWithNull, "B")); assertEquals(-1, ArrayUtil.indexOf(arrayWithNull, "C")); @@ -404,7 +323,6 @@ public void testIndexOf() { assertEquals(-1, ArrayUtil.indexOf(arrayWithNull, "E")); String[] arrayWithDoubleElements = { "B", "A", "C", "B", "C" }; assertEquals(-1, ArrayUtil.indexOf(arrayWithDoubleElements, null)); - assertEquals(-1, ArrayUtil.indexOf(null, "A")); assertEquals(1, ArrayUtil.indexOf(arrayWithDoubleElements, "A")); assertEquals(0, ArrayUtil.indexOf(arrayWithDoubleElements, "B")); assertEquals(2, ArrayUtil.indexOf(arrayWithDoubleElements, "C")); diff --git a/key.util/src/test/java/org/key_project/util/testcase/java/CollectionUtilTest.java b/key.util/src/test/java/org/key_project/util/testcase/java/CollectionUtilTest.java index a8e0c8dab81..409309555a4 100644 --- a/key.util/src/test/java/org/key_project/util/testcase/java/CollectionUtilTest.java +++ b/key.util/src/test/java/org/key_project/util/testcase/java/CollectionUtilTest.java @@ -6,6 +6,7 @@ import java.util.*; import java.util.function.Predicate; +import org.jspecify.annotations.Nullable; import org.key_project.util.java.CollectionUtil; import org.key_project.util.java.IFilterWithException; @@ -37,11 +38,6 @@ public void testSearchAll() { // Test single not existing value found = CollectionUtil.searchAll(collection, "E"::equals); assertList(found); - // Test null - found = CollectionUtil.searchAll(collection, null); - assertList(found); - found = CollectionUtil.searchAll(null, "E"::equals); - assertList(found); // Test multible values found = CollectionUtil.searchAll(collection, element -> "A".equals(element) || "C".equals(element)); @@ -97,13 +93,11 @@ protected static void assertList(List actual, String... expected) { */ @Test public void testIndexOf_Iterator() { - List list = new LinkedList<>(); + List<@Nullable String> list = new LinkedList<>(); list.add("A"); list.add("B"); list.add("C"); - assertEquals(-1, CollectionUtil.indexOf((Iterator) null, null)); assertEquals(-1, CollectionUtil.indexOf(list.iterator(), null)); - assertEquals(-1, CollectionUtil.indexOf(null, "A")); assertEquals(0, CollectionUtil.indexOf(list.iterator(), "A")); assertEquals(1, CollectionUtil.indexOf(list.iterator(), "B")); assertEquals(2, CollectionUtil.indexOf(list.iterator(), "C")); @@ -153,9 +147,6 @@ public void testSearchAndRemoveWithException() throws Throwable { assertNull(CollectionUtil.searchAndRemoveWithException(collection, (IFilterWithException) "E"::equals)); assertEquals(collection, List.of()); - assertNull(CollectionUtil.searchAndRemoveWithException(collection, null)); - assertNull(CollectionUtil.searchAndRemoveWithException(null, - (IFilterWithException) "E"::equals)); assertEquals(collection, List.of()); } @@ -183,8 +174,6 @@ public void testSearchAndRemove() { assertEquals(collection, List.of()); assertNull(CollectionUtil.searchAndRemove(collection, "E"::equals)); assertEquals(collection, List.of()); - assertNull(CollectionUtil.searchAndRemove(collection, null)); - assertNull(CollectionUtil.searchAndRemove(null, "E"::equals)); assertEquals(collection, List.of()); } @@ -193,8 +182,6 @@ public void testSearchAndRemove() { */ @Test public void testRemoveFirst() { - // Test null - assertNull(CollectionUtil.removeFirst(null)); // Test empty collection Set set = new HashSet<>(); List list = new ArrayList<>(); @@ -223,28 +210,22 @@ public void testRemoveFirst() { @Test public void testContainsSame_List() { // Create model - List empty = new LinkedList<>(); - List one = Collections.singletonList("A"); - List oneCopy = Collections.singletonList("A"); - List oneDifferent = Collections.singletonList("B"); - List two = Arrays.asList("A", "B"); - List twoCopy = Arrays.asList("A", "B"); - List twoDifferent = Arrays.asList("C", "B"); - List twoChangedOrder = Arrays.asList("B", "A"); - List three = Arrays.asList("A", "B", "A"); - List threeCopy = Arrays.asList("A", "B", "A"); - List threeDifferent = Arrays.asList("A", "B", "B"); - List threeChangedOrder = Arrays.asList("A", "A", "B"); - List four = Arrays.asList("A", "B", null, "A"); - List fourCopy = Arrays.asList("A", "B", null, "A"); - List fourDifferent = Arrays.asList("A", null, null, "B"); - List fourChangedOrder = Arrays.asList(null, "A", "A", "B"); - // Test handlig of null - assertTrue(CollectionUtil.containsSame(null, null)); - assertTrue(CollectionUtil.containsSame(empty, null)); - assertTrue(CollectionUtil.containsSame(null, empty)); - assertFalse(CollectionUtil.containsSame(null, one)); - assertFalse(CollectionUtil.containsSame(one, null)); + List<@Nullable String> empty = new LinkedList<>(); + List<@Nullable String> one = Collections.singletonList("A"); + List<@Nullable String> oneCopy = Collections.singletonList("A"); + List<@Nullable String> oneDifferent = Collections.singletonList("B"); + List<@Nullable String> two = Arrays.asList("A", "B"); + List<@Nullable String> twoCopy = Arrays.asList("A", "B"); + List<@Nullable String> twoDifferent = Arrays.asList("C", "B"); + List<@Nullable String> twoChangedOrder = Arrays.asList("B", "A"); + List<@Nullable String> three = Arrays.asList("A", "B", "A"); + List<@Nullable String> threeCopy = Arrays.asList("A", "B", "A"); + List<@Nullable String> threeDifferent = Arrays.asList("A", "B", "B"); + List<@Nullable String> threeChangedOrder = Arrays.asList("A", "A", "B"); + List<@Nullable String> four = Arrays.asList("A", "B", null, "A"); + List<@Nullable String> fourCopy = Arrays.asList("A", "B", null, "A"); + List<@Nullable String> fourDifferent = Arrays.asList("A", null, null, "B"); + List<@Nullable String> fourChangedOrder = Arrays.asList(null, "A", "A", "B"); // Test one elements assertTrue(CollectionUtil.containsSame(one, one)); assertTrue(CollectionUtil.containsSame(one, oneCopy)); @@ -322,12 +303,6 @@ public void testContainsSame_Set() { Set twoCopy = Set.of("A", "B"); Set twoDifferent = Set.of("C", "B"); Set twoChangedOrder = Set.of("B", "A"); - // Test handlig of null - assertTrue(CollectionUtil.containsSame(null, null)); - assertTrue(CollectionUtil.containsSame(empty, null)); - assertTrue(CollectionUtil.containsSame(null, empty)); - assertFalse(CollectionUtil.containsSame(null, one)); - assertFalse(CollectionUtil.containsSame(one, null)); // Test one element assertTrue(CollectionUtil.containsSame(one, one)); assertTrue(CollectionUtil.containsSame(one, oneCopy)); @@ -360,9 +335,6 @@ public void testCount() { list.add("B"); list.add("A"); // Test counts - assertEquals(0, CollectionUtil.count(null, null)); - assertEquals(0, CollectionUtil.count(list, null)); - assertEquals(0, CollectionUtil.count(null, element -> false)); assertEquals(3, CollectionUtil.count(list, "A"::equals)); assertEquals(2, CollectionUtil.count(list, "B"::equals)); assertEquals(1, CollectionUtil.count(list, "C"::equals)); @@ -375,15 +347,13 @@ public void testCount() { @Test public void testContains() { // Create model - List list = new LinkedList<>(); + List<@Nullable String> list = new LinkedList<>(); list.add("A"); list.add("B"); list.add("C"); list.add("D"); // Test null parameter - assertFalse(CollectionUtil.contains(null, "A")); assertFalse(CollectionUtil.contains(list, null)); - assertFalse(CollectionUtil.contains(null, null)); // Test values assertTrue(CollectionUtil.contains(list, "A")); assertTrue(CollectionUtil.contains(list, "B")); @@ -406,8 +376,6 @@ public void testSearch() { assertEquals("C", CollectionUtil.search(collection, "C"::equals)); assertEquals("D", CollectionUtil.search(collection, "D"::equals)); assertNull(CollectionUtil.search(collection, "E"::equals)); - assertNull(CollectionUtil.search(collection, null)); - assertNull(CollectionUtil.search(null, "E"::equals)); } /** @@ -415,7 +383,7 @@ public void testSearch() { */ @Test public void testRemoveComplete() { - List collection = + List<@Nullable String> collection = new ArrayList<>(Arrays.asList("A", "B", "C", "A", "A", "B", "A", "D")); assertFalse(CollectionUtil.removeComplete(collection, null)); assertEquals("A", collection.get(0)); @@ -426,7 +394,6 @@ public void testRemoveComplete() { assertEquals("B", collection.get(5)); assertEquals("A", collection.get(6)); assertEquals("D", collection.get(7)); - assertFalse(CollectionUtil.removeComplete(null, "A")); assertEquals("A", collection.get(0)); assertEquals("B", collection.get(1)); assertEquals("C", collection.get(2)); @@ -468,9 +435,7 @@ public void testRemoveComplete() { @Test public void testAddAll_Iterable() { List collection = new LinkedList<>(); - CollectionUtil.addAll(null, List.of("A")); assertEquals(0, collection.size()); - CollectionUtil.addAll(collection, null); assertEquals(0, collection.size()); CollectionUtil.addAll(collection, List.of("A")); assertEquals(1, collection.size()); @@ -503,44 +468,11 @@ public void testAddAll_Iterable() { assertEquals("G", collection.get(6)); } - /** - * Test for {@link CollectionUtil#isEmpty(java.util.Collection)} - */ - @Test - public void testIsEmpty_Collection() { - assertTrue(CollectionUtil.isEmpty((Collection) null)); - List collection = new LinkedList<>(); - assertTrue(CollectionUtil.isEmpty(collection)); - collection.add("A"); - assertFalse(CollectionUtil.isEmpty(collection)); - collection.add("B"); - assertFalse(CollectionUtil.isEmpty(collection)); - collection.add("C"); - assertFalse(CollectionUtil.isEmpty(collection)); - } - - /** - * Test for {@link CollectionUtil#isEmpty(java.util.Map)} - */ - @Test - public void testIsEmpty_Map() { - assertTrue(CollectionUtil.isEmpty((Map) null)); - Map map = new HashMap<>(); - assertTrue(CollectionUtil.isEmpty(map)); - map.put("A", "A"); - assertFalse(CollectionUtil.isEmpty(map)); - map.put("B", "B"); - assertFalse(CollectionUtil.isEmpty(map)); - map.put("C", "C"); - assertFalse(CollectionUtil.isEmpty(map)); - } - /** * Test for {@link CollectionUtil#toString(java.util.Collection, String)} */ @Test public void testToString_Collection_String() { - assertEquals("", CollectionUtil.toString(null, " | ")); List collection = new LinkedList<>(); assertEquals("", CollectionUtil.toString(collection, " | ")); collection.add("A"); @@ -551,7 +483,6 @@ public void testToString_Collection_String() { assertEquals("A | B | C", CollectionUtil.toString(collection, " | ")); collection.add("D"); assertEquals("A | B | C | D", CollectionUtil.toString(collection, " | ")); - assertEquals("ABCD", CollectionUtil.toString(collection, null)); } /** @@ -559,7 +490,6 @@ public void testToString_Collection_String() { */ @Test public void testToString_Collection() { - assertEquals("", CollectionUtil.toString(null)); List collection = new LinkedList<>(); assertEquals("", CollectionUtil.toString(collection)); collection.add("A"); diff --git a/key.util/src/test/java/org/key_project/util/testcase/java/IOUtilTest.java b/key.util/src/test/java/org/key_project/util/testcase/java/IOUtilTest.java index 94f6b51b29e..a9863593c60 100644 --- a/key.util/src/test/java/org/key_project/util/testcase/java/IOUtilTest.java +++ b/key.util/src/test/java/org/key_project/util/testcase/java/IOUtilTest.java @@ -14,6 +14,7 @@ import javax.xml.parsers.SAXParser; import javax.xml.parsers.SAXParserFactory; +import org.jspecify.annotations.Nullable; import org.key_project.util.helper.HelperClassForUtilityTests; import org.key_project.util.java.IOUtil; import org.key_project.util.java.IOUtil.IFileVisitor; @@ -42,22 +43,6 @@ public void testGetCurrentDirectory() { assertNotNull(currentDir); } - /** - * Tests {@link IOUtil#exists(File)} - */ - @Test - public void testExists() throws IOException { - assertFalse(IOUtil.exists(null)); - File tempFile = File.createTempFile("IOUtilTest_", ".testExists"); - assertTrue(IOUtil.exists(tempFile)); - tempFile.delete(); - assertFalse(IOUtil.exists(tempFile)); - File tempDir = IOUtil.createTempDirectory("IOUtilTest_", ".testExists"); - assertTrue(IOUtil.exists(tempDir)); - IOUtil.delete(tempDir); - assertFalse(IOUtil.exists(tempDir)); - } - /** * {@link IOUtil#contains(Iterable, File)}. */ @@ -84,10 +69,10 @@ public void testContains_Iterable() throws IOException { File noSubFile = HelperClassForUtilityTests.createFile(new File(noFolder, "Hello.txt"), "Hello"); List parents = Arrays.asList(yesDir, alsoYesDir); - assertFalse(IOUtil.contains((Iterable) null, yesFile)); - assertFalse(IOUtil.contains(parents, null)); - assertFalse(IOUtil.contains((Iterable) null, null)); - assertFalse(IOUtil.contains(parents, yesDir.getParentFile())); + File yesDirParent = yesDir.getParentFile(); + if (yesDirParent != null) { + assertFalse(IOUtil.contains(yesDir, yesDirParent)); + } assertTrue(IOUtil.contains(parents, yesDir)); assertTrue(IOUtil.contains(parents, yesFile)); assertTrue(IOUtil.contains(parents, yesFolder)); @@ -125,10 +110,10 @@ public void testContains_File() throws IOException { File noFolder = HelperClassForUtilityTests.createFolder(new File(noDir, "yesSub")); File noSubFile = HelperClassForUtilityTests.createFile(new File(noFolder, "Hello.txt"), "Hello"); - assertFalse(IOUtil.contains((File) null, yesFile)); - assertFalse(IOUtil.contains(yesDir, null)); - assertFalse(IOUtil.contains((File) null, null)); - assertFalse(IOUtil.contains(yesDir, yesDir.getParentFile())); + File yesDirParent = yesDir.getParentFile(); + if (yesDirParent != null) { + assertFalse(IOUtil.contains(yesDir, yesDirParent)); + } assertTrue(IOUtil.contains(yesDir, yesDir)); assertTrue(IOUtil.contains(yesDir, yesFile)); assertTrue(IOUtil.contains(yesDir, yesFolder)); @@ -148,7 +133,6 @@ public void testContains_File() throws IOException { */ @Test public void testUnifyLineBreaks() throws IOException { - doTestUnifyLineBreaks(null, null); doTestUnifyLineBreaks("A\nB\rC\n\nD\r\rE", "A\nB\nC\n\nD\n\nE"); doTestUnifyLineBreaks("A\r\nE", "A\nE"); } @@ -161,9 +145,7 @@ public void testUnifyLineBreaks() throws IOException { * @throws IOException Occurred Exception. */ protected void doTestUnifyLineBreaks(String toTest, String expected) throws IOException { - ByteArrayInputStream in = - toTest != null ? new ByteArrayInputStream(toTest.getBytes(StandardCharsets.UTF_8)) - : null; + ByteArrayInputStream in = new ByteArrayInputStream(toTest.getBytes(StandardCharsets.UTF_8)); InputStream converted = IOUtil.unifyLineBreaks(in); assertEquals(expected, IOUtil.readFrom(converted)); } @@ -231,9 +213,6 @@ public void testVisit() throws IOException { IOUtil.writeTo(new FileOutputStream(text), "Text.txt"); // Create visitor LogVisitor visitor = new LogVisitor(); - // Test null - IOUtil.visit(null, visitor); - assertEquals(0, visitor.getVisitedFiles().size()); // Test visiting IOUtil.visit(tempDir, visitor); // Ensure same order in all operating systems @@ -305,24 +284,8 @@ public void testSearch() throws IOException { IOUtil.writeTo(new FileOutputStream(text), "Text.txt"); // Create filter Predicate filter = element -> element.getName().contains("Sub"); - // Test null - List result = IOUtil.search(null, filter); - assertEquals(0, result.size()); - // Test no filter - result = IOUtil.search(tempDir, null); - result.sort(Comparator.comparing(File::getAbsolutePath)); // Ensure same order in all - // operating systems - assertEquals(8, result.size()); - assertEquals(tempDir, result.get(0)); - assertEquals(text, result.get(1)); - assertEquals(emptyFolder, result.get(2)); - assertEquals(subDir, result.get(3)); - assertEquals(subFile, result.get(4)); - assertEquals(subSubDir, result.get(5)); - assertEquals(subSubA, result.get(6)); - assertEquals(subSubB, result.get(7)); // Test with filter - result = IOUtil.search(tempDir, filter); + List result = IOUtil.search(tempDir, filter); result.sort(Comparator.comparing(File::getAbsolutePath)); // Ensure same order in all // operating systems assertEquals(4, result.size()); @@ -340,7 +303,6 @@ public void testSearch() throws IOException { */ @Test public void testGetFileExtension() { - assertNull(IOUtil.getFileExtension(null)); assertNull(IOUtil.getFileExtension(new File(""))); assertNull(IOUtil.getFileExtension(new File("hello"))); assertNull(IOUtil.getFileExtension(new File("path", "hello"))); @@ -369,7 +331,6 @@ public void testGetHomeDirectory() { */ @Test public void testGetFileNameWithoutExtension() { - assertNull(IOUtil.getFileNameWithoutExtension(null)); assertEquals("test", IOUtil.getFileNameWithoutExtension("test.txt")); assertEquals("hello.world", IOUtil.getFileNameWithoutExtension("hello.world.diagram")); assertEquals("", IOUtil.getFileNameWithoutExtension(".project")); @@ -391,7 +352,9 @@ public void testCreateTempDirectory() throws IOException { assertTrue(tempDir.getName().startsWith("IOUtilTest")); assertTrue(tempDir.getName().endsWith("testCreateTempDirectory")); } finally { - IOUtil.delete(tempDir); + if (tempDir != null) { + IOUtil.delete(tempDir); + } } } @@ -461,8 +424,6 @@ public void testComputeLineInformation_File() throws IOException { File textFile = new File(HelperClassForUtilityTests.RESOURCE_DIRECTORY + File.separator + "lineIndicesTest" + File.separator + "Text.txt"); assertTrue(textFile.isFile(), "File '" + textFile + "' does not exist."); - // Test null - assertLineInformation((File) null); // Test unix file assertLineInformation(convertTextFile(textFile, "Text_Unix.txt", "\r"), 0, 1, 2, 9, 16, 17, 24, 50, 23661, 23662, 23663, 23671, 23672); @@ -550,8 +511,8 @@ public void testComputeLineInformation_InputStream() throws IOException { * @throws IOException Occurred Exception. */ protected void doTestComputeLineInformation_InputStream(String newLine) throws IOException { - // Test null - assertLineInformation(newLine, new String[0]); + // Test empty string + assertLineInformation(newLine, ""); // Test single line assertLineInformation(newLine, "Hello World!"); // Test two line @@ -591,32 +552,28 @@ protected void doTestComputeLineInformation_InputStream(String newLine) throws I * @throws IOException Occurred Exception. */ protected void assertLineInformation(String newLine, String... textLines) throws IOException { - if (textLines != null) { - StringBuilder sb = new StringBuilder(); - LineInformation[] expectedInfos = new LineInformation[textLines.length]; - int lastIndex = 0; - for (int i = 0; i < textLines.length; i++) { - // Compute tabs - List tabIndices = new LinkedList<>(); - char[] lineChars = textLines[i].toCharArray(); - for (int j = 0; j < lineChars.length; j++) { - if ('\t' == lineChars[j]) { - tabIndices.add(j); - } - } - // Compute line - expectedInfos[i] = new LineInformation(lastIndex, tabIndices); - sb.append(textLines[i]); - lastIndex += textLines[i].length(); - if (i < textLines.length - 1) { - sb.append(newLine); - lastIndex += newLine.length(); + StringBuilder sb = new StringBuilder(); + LineInformation[] expectedInfos = new LineInformation[textLines.length]; + int lastIndex = 0; + for (int i = 0; i < textLines.length; i++) { + // Compute tabs + List tabIndices = new LinkedList<>(); + char[] lineChars = textLines[i].toCharArray(); + for (int j = 0; j < lineChars.length; j++) { + if ('\t' == lineChars[j]) { + tabIndices.add(j); } } - assertLineInformation(sb.length() >= 1 ? sb.toString() : null, expectedInfos); - } else { - assertLineInformation(null, new LineInformation[0]); + // Compute line + expectedInfos[i] = new LineInformation(lastIndex, tabIndices); + sb.append(textLines[i]); + lastIndex += textLines[i].length(); + if (i < textLines.length - 1) { + sb.append(newLine); + lastIndex += newLine.length(); + } } + assertLineInformation(sb.toString(), expectedInfos); } /** @@ -628,8 +585,7 @@ protected void assertLineInformation(String newLine, String... textLines) throws */ protected void assertLineInformation(String text, LineInformation... expectedInfos) throws IOException { - LineInformation[] result = IOUtil.computeLineInformation( - text != null ? new ByteArrayInputStream(text.getBytes(StandardCharsets.UTF_8)) : null); + LineInformation[] result = IOUtil.computeLineInformation(new ByteArrayInputStream(text.getBytes(StandardCharsets.UTF_8))); assertNotNull(result, text); assertEquals(expectedInfos.length, result.length, text); for (int i = 0; i < expectedInfos.length; i++) { @@ -652,13 +608,8 @@ protected void assertLineInformation(String text, LineInformation... expectedInf public void testWriteTo() throws IOException { File tempFile = null; try { - // Test null stream, nothing should happen String content = "Hello World!"; - IOUtil.writeTo(null, content); - // Test null content ByteArrayOutputStream out = new ByteArrayOutputStream(); - IOUtil.writeTo(out, null); - assertEquals(0, out.toByteArray().length); // Test writing to memory stream out = new ByteArrayOutputStream(); IOUtil.writeTo(out, content); @@ -697,7 +648,7 @@ public void testWriteTo_Charstet() throws Exception { protected byte[] doWriteCharsetAsXmlTest(String text, Charset encoding) throws Exception { // Create XML StringBuilder sb = new StringBuilder(); - XMLUtil.appendXmlHeader(encoding != null ? encoding.displayName() : null, sb); + XMLUtil.appendXmlHeader(encoding.displayName(), sb); Map attributes = new LinkedHashMap<>(); attributes.put("text", XMLUtil.encodeText(text)); XMLUtil.appendEmptyTag(0, "root", attributes, sb); @@ -724,7 +675,7 @@ private static final class RootHandler extends DefaultHandler { /** * The parsed text. */ - private String text; + private @Nullable String text; /** * {@inheritDoc} @@ -748,7 +699,7 @@ public void startElement(String uri, String localName, String qName, Attributes * * @return The parsed text. */ - public String getText() { + public @Nullable String getText() { return text; } } @@ -758,8 +709,6 @@ public String getText() { */ @Test public void testReadFrom_File() throws IOException { - // Test null - assertNull(IOUtil.readFrom((File) null)); File tempFile = File.createTempFile("IOUtilTest", "testReadFrom_File"); try { // Test not existing file @@ -780,7 +729,6 @@ public void testReadFrom_File() throws IOException { @Test public void testReadFrom_InputStream() { try { - doTestReadFrom(null); doTestReadFrom("One Line"); doTestReadFrom("First Line\n\rSecond Line"); doTestReadFrom("One Line\r"); @@ -794,12 +742,8 @@ public void testReadFrom_InputStream() { } protected void doTestReadFrom(String text) throws IOException { - if (text != null) { - assertEquals(text, + assertEquals(text, IOUtil.readFrom(new ByteArrayInputStream(text.getBytes(StandardCharsets.UTF_8)))); - } else { - assertNull(IOUtil.readFrom((InputStream) null)); - } } /** @@ -807,8 +751,6 @@ protected void doTestReadFrom(String text) throws IOException { */ @Test public void testDelete() throws IOException { - // Test null - IOUtil.delete(null); // No exception expected // Test existing file File tmpFile = File.createTempFile("IOUtilTest", "deleteMe"); assertTrue(tmpFile.exists()); @@ -844,10 +786,6 @@ public void testDelete() throws IOException { */ @Test public void testCopy() throws IOException { - doTestCopy(null); - assertFalse(IOUtil.copy((InputStream) null, null)); - assertFalse(IOUtil.copy( - new ByteArrayInputStream("NotCopied".getBytes(StandardCharsets.UTF_8)), null)); doTestCopy("One Line"); doTestCopy("First Line\n\rSecond Line"); doTestCopy("One Line\r"); @@ -864,18 +802,14 @@ public void testCopy() throws IOException { * @throws IOException Occurred Exception. */ protected void doTestCopy(String text) throws IOException { - if (text != null) { - byte[] inBytes = text.getBytes(StandardCharsets.UTF_8); - ByteArrayInputStream in = new ByteArrayInputStream(inBytes); - ByteArrayOutputStream out = new ByteArrayOutputStream(); - assertTrue(IOUtil.copy(in, out)); - byte[] outBytes = out.toByteArray(); - assertEquals(inBytes.length, outBytes.length); - for (int i = 0; i < inBytes.length; i++) { - assertEquals(inBytes[i], outBytes[i]); - } - } else { - assertFalse(IOUtil.copy(null, new ByteArrayOutputStream())); + byte[] inBytes = text.getBytes(StandardCharsets.UTF_8); + ByteArrayInputStream in = new ByteArrayInputStream(inBytes); + ByteArrayOutputStream out = new ByteArrayOutputStream(); + assertTrue(IOUtil.copy(in, out)); + byte[] outBytes = out.toByteArray(); + assertEquals(inBytes.length, outBytes.length); + for (int i = 0; i < inBytes.length; i++) { + assertEquals(inBytes[i], outBytes[i]); } } @@ -884,7 +818,6 @@ protected void doTestCopy(String text) throws IOException { */ @Test public void testGetClassLocation() { - assertNull(IOUtil.getClassLocation(null)); assertNotNull(IOUtil.getClassLocation(getClass())); } @@ -893,7 +826,6 @@ public void testGetClassLocation() { */ @Test public void testGetProjectRoot() { - assertNull(IOUtil.getProjectRoot(null)); assertNotNull(IOUtil.getProjectRoot(getClass())); } @@ -969,7 +901,6 @@ public void testToFileString() throws MalformedURLException { */ @Test public void testValidateOSIndependentFileName() { - assertNull(IOUtil.validateOSIndependentFileName(null)); assertEquals("Hello_World", IOUtil.validateOSIndependentFileName("Hello World")); assertEquals("Hello_World_txt", IOUtil.validateOSIndependentFileName("Hello World.txt")); assertEquals("Hello__World_txt", IOUtil.validateOSIndependentFileName("Hello<>World.txt")); diff --git a/key.util/src/test/java/org/key_project/util/testcase/java/NumberUtilTest.java b/key.util/src/test/java/org/key_project/util/testcase/java/NumberUtilTest.java index 84c0be704fe..836fa8b26c2 100644 --- a/key.util/src/test/java/org/key_project/util/testcase/java/NumberUtilTest.java +++ b/key.util/src/test/java/org/key_project/util/testcase/java/NumberUtilTest.java @@ -32,12 +32,6 @@ public void testParseFullInt() { assertEquals(123, NumberUtil.parseFullInt(NumberUtil.toFullString(123))); assertEquals(Integer.MAX_VALUE, NumberUtil.parseFullInt(NumberUtil.toFullString(Integer.MAX_VALUE))); - try { - NumberUtil.parseFullInt(null); - fail(); - } catch (NumberFormatException e) { - assertEquals("Text not defined.", e.getMessage()); - } } /** @@ -56,12 +50,6 @@ public void testParseFullLong() { assertEquals(123, NumberUtil.parseFullLong(NumberUtil.toFullString(123))); assertEquals(Long.MAX_VALUE, NumberUtil.parseFullLong(NumberUtil.toFullString(Long.MAX_VALUE))); - try { - NumberUtil.parseFullInt(null); - fail(); - } catch (NumberFormatException e) { - assertEquals("Text not defined.", e.getMessage()); - } } /** diff --git a/key.util/src/test/java/org/key_project/util/testcase/java/StringUtilTest.java b/key.util/src/test/java/org/key_project/util/testcase/java/StringUtilTest.java index 9294b92aa93..249055693f5 100644 --- a/key.util/src/test/java/org/key_project/util/testcase/java/StringUtilTest.java +++ b/key.util/src/test/java/org/key_project/util/testcase/java/StringUtilTest.java @@ -5,6 +5,7 @@ import java.util.Comparator; +import org.jspecify.annotations.Nullable; import org.key_project.util.java.StringUtil; import org.junit.jupiter.api.Test; @@ -163,7 +164,6 @@ public void testToSingleLinedString() { public void testReplaceAll() { String text = "ABCDABCDABCDABCD"; assertNull(StringUtil.replaceAll(null, new char[] {}, 'X')); - assertEquals(text, StringUtil.replaceAll(text, null, 'X')); assertEquals(text, StringUtil.replaceAll(text, new char[] {}, 'X')); assertEquals("XBCDXBCDXBCDXBCD", StringUtil.replaceAll(text, new char[] { 'A' }, 'X')); assertEquals("AXCDAXCDAXCDAXCD", StringUtil.replaceAll(text, new char[] { 'B' }, 'X')); @@ -209,13 +209,6 @@ public void testRepeat() { assertEquals("#####", StringUtil.repeat("#", 5)); // Test line with multiple characters assertEquals("ABABAB", StringUtil.repeat("AB", 3)); - - // Test null text - try { - assertEquals("nullnullnullnull", StringUtil.repeat(null, 4)); - fail(); - } catch (NullPointerException expected) { - } } /** @@ -223,7 +216,7 @@ public void testRepeat() { */ @Test public void testCreateIgnoreCaseComparator() { - Comparator c = StringUtil.createIgnoreCaseComparator(); + Comparator<@Nullable String> c = StringUtil.createIgnoreCaseComparator(); assertNotNull(c); assertSame("A".compareToIgnoreCase("A"), c.compare("A", "A")); assertSame("A".compareToIgnoreCase("a"), c.compare("A", "a")); diff --git a/key.util/src/test/java/org/key_project/util/testcase/java/XMLUtilTest.java b/key.util/src/test/java/org/key_project/util/testcase/java/XMLUtilTest.java index 281cfbbb497..5fa925e12b6 100644 --- a/key.util/src/test/java/org/key_project/util/testcase/java/XMLUtilTest.java +++ b/key.util/src/test/java/org/key_project/util/testcase/java/XMLUtilTest.java @@ -26,15 +26,9 @@ public class XMLUtilTest { */ @Test public void testReplaceTags() { - assertNull(XMLUtil.replaceTags(null, null)); - assertNull(XMLUtil.replaceTags("Hello", null)); - assertNull(XMLUtil.replaceTags(null, new LoggingReplacer("|"))); assertReplaceTags("Hello World", "Hello World", "|"); assertReplaceTags("Hello
World", "|Hello| World|", "|", "", "
", ""); - assertReplaceTags("Hello World", "Hello World", null); - assertReplaceTags("Hello
World", "Hello World", null, "", "
", - ""); assertReplaceTags("Hello
World", "|Hello| World", "|", "", "
"); assertReplaceTags("Hello
World", "Hello| World|", "|", "
", ""); assertReplaceTags("Hello World", "|Hello World|", "|", @@ -49,7 +43,7 @@ public void testReplaceTags() { * @param text The text to execute * {@link XMLUtil#replaceTags(String, org.key_project.util.java.XMLUtil.ITagReplacer)} * on. - * @param expectedResult The expected result. + * @param expectedResult The expected result.N * @param fixedReplacement The fixed replacement to use. * @param expectedTags The expected found tags. */ @@ -115,7 +109,6 @@ public List getLog() { */ @Test public void testRemoveTags() { - assertNull(XMLUtil.removeTags(null)); assertEquals("Hello World", XMLUtil.removeTags("Hello World")); assertEquals("Hello World", XMLUtil.removeTags("Hello
World")); assertEquals("Hello World", XMLUtil.removeTags("Hello
World")); @@ -130,8 +123,6 @@ public void testRemoveTags() { */ @Test public void testEncodeText() { - // Test null - assertNull(XMLUtil.encodeText(null)); // Test empty string assertEquals(StringUtil.EMPTY_STRING, XMLUtil.encodeText(StringUtil.EMPTY_STRING)); // Text XML tags From 9870edc8c7e10ba40d380d626c7c99ba8014adff Mon Sep 17 00:00:00 2001 From: Florian Lanzinger Date: Tue, 30 Apr 2024 19:27:49 +0200 Subject: [PATCH 35/37] Fix NoSuchElementException in JavaInfo --- .../java/de/uka/ilkd/key/java/JavaInfo.java | 4 +- .../java/de/uka/ilkd/key/smt/RuleAppSMT.java | 155 ------------------ 2 files changed, 3 insertions(+), 156 deletions(-) delete mode 100644 key.core/src/main/java/de/uka/ilkd/key/smt/RuleAppSMT.java diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/JavaInfo.java b/key.core/src/main/java/de/uka/ilkd/key/java/JavaInfo.java index 3e03d7b704c..3df934302d5 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/JavaInfo.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/JavaInfo.java @@ -1061,7 +1061,9 @@ public ProgramVariable getAttribute(final String attributeName, Sort s) { */ public ProgramVariable getCanonicalFieldProgramVariable(String fieldName, KeYJavaType kjt) { ImmutableList allAttributes = getAllAttributes(fieldName, kjt, false); - if (kjt.getJavaType() instanceof ArrayType) { + if (allAttributes.isEmpty()) { + return null; + } else if (kjt.getJavaType() instanceof ArrayType) { return allAttributes.head(); } else { return allAttributes.reverse().head(); diff --git a/key.core/src/main/java/de/uka/ilkd/key/smt/RuleAppSMT.java b/key.core/src/main/java/de/uka/ilkd/key/smt/RuleAppSMT.java deleted file mode 100644 index d5c771c2898..00000000000 --- a/key.core/src/main/java/de/uka/ilkd/key/smt/RuleAppSMT.java +++ /dev/null @@ -1,155 +0,0 @@ -/* This file is part of KeY - https://key-project.org - * KeY is licensed under the GNU General Public License Version 2 - * SPDX-License-Identifier: GPL-2.0-only */ -package de.uka.ilkd.key.smt; - -import de.uka.ilkd.key.java.Services; -import de.uka.ilkd.key.logic.PosInOccurrence; -import de.uka.ilkd.key.logic.TermServices; -import de.uka.ilkd.key.proof.Goal; -import de.uka.ilkd.key.rule.AbstractBuiltInRuleApp; -import de.uka.ilkd.key.rule.BuiltInRule; -import de.uka.ilkd.key.rule.RuleApp; - -import org.key_project.logic.Name; -import org.key_project.util.collection.ImmutableList; - -import org.jspecify.annotations.NonNull; - -/** - * The rule application that is used when a goal is closed by means of an external solver. So far it - * stores the rule that that has been used and a title containing some information for the user. - */ -public class RuleAppSMT extends AbstractBuiltInRuleApp { - - public static final SMTRule RULE = new SMTRule(); - private final String title; - private final String successfulSolverName; - - - RuleAppSMT(SMTRule rule, String successfulSolverName) { - super(rule, null, null); - this.title = "SMT: " + successfulSolverName; - this.successfulSolverName = successfulSolverName; - } - - RuleAppSMT(SMTRule rule, String successfulSolverName, - ImmutableList unsatCore) { - super(rule, null, unsatCore); - this.title = "SMT: " + successfulSolverName; - this.successfulSolverName = successfulSolverName; - } - - @Override - public RuleAppSMT replacePos(PosInOccurrence newPos) { - return this; - } - - @Override - public boolean complete() { - return true; - } - - public String getTitle() { - return title; - } - - public String getSuccessfulSolverName() { - return successfulSolverName; - } - - @Override - public PosInOccurrence posInOccurrence() { - return null; - } - - @Override - public BuiltInRule rule() { - return RULE; - } - - @Override - public String displayName() { - return title; - } - - public static class SMTRule implements BuiltInRule { - public static final Name name = new Name("SMTRule"); - - public RuleAppSMT createApp(String successfulSolverName) { - return new RuleAppSMT(this, successfulSolverName); - } - - /** - * Create a new rule application with the given solver name and unsat core. - * - * @param successfulSolverName solver that produced this result - * @param unsatCore formulas required to prove the result - * @return rule application instance - */ - public RuleAppSMT createApp(String successfulSolverName, - ImmutableList unsatCore) { - return new RuleAppSMT(this, successfulSolverName, unsatCore); - } - - @Override - public RuleAppSMT createApp(PosInOccurrence pos, TermServices services) { - return new RuleAppSMT(this, ""); - } - - - @Override - public boolean isApplicable(Goal goal, PosInOccurrence pio) { - return false; - } - - - @NonNull - @Override - public ImmutableList apply(Goal goal, Services services, RuleApp ruleApp) { - if (goal.proof().getInitConfig().getJustifInfo().getJustification(RULE) == null) { - goal.proof().getInitConfig().registerRule(RULE, () -> false); - } - - // RuleAppSMT app = (RuleAppSMT) ruleApp; - // goal.node().getNodeInfo().setBranchLabel(app.getTitle()); - - return goal.split(0); - } - - /** - * {@inheritDoc} - */ - @Override - public boolean isApplicableOnSubTerms() { - return false; - } - - @Override - public String displayName() { - return "SMT"; - } - - public String toString() { - return displayName(); - } - - @Override - public Name name() { - return name; - } - - } - - @Override - public RuleAppSMT setIfInsts(ImmutableList ifInsts) { - setMutable(ifInsts); - return this; - } - - @Override - public RuleAppSMT tryToInstantiate(Goal goal) { - return this; - } - -} From 9b978f9acca5a14f1bbb7a8e9c8bba0dca2f18e4 Mon Sep 17 00:00:00 2001 From: Florian Lanzinger Date: Tue, 30 Apr 2024 20:43:12 +0200 Subject: [PATCH 36/37] Fix more NoSuchElementExceptions --- .../macros/StartAuxiliaryBlockComputationMacro.java | 2 +- .../macros/StartAuxiliaryLoopComputationMacro.java | 2 +- .../macros/StartAuxiliaryMethodComputationMacro.java | 2 +- .../ilkd/key/informationflow/po/IFProofObligationVars.java | 7 ++++++- key.core/src/main/java/de/uka/ilkd/key/rule/Taclet.java | 4 ++-- .../ilkd/key/speclang/jml/translation/JMLSpecFactory.java | 5 +++-- 6 files changed, 14 insertions(+), 8 deletions(-) diff --git a/key.core/src/main/java/de/uka/ilkd/key/informationflow/macros/StartAuxiliaryBlockComputationMacro.java b/key.core/src/main/java/de/uka/ilkd/key/informationflow/macros/StartAuxiliaryBlockComputationMacro.java index a7b80f23363..65d08de9837 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/informationflow/macros/StartAuxiliaryBlockComputationMacro.java +++ b/key.core/src/main/java/de/uka/ilkd/key/informationflow/macros/StartAuxiliaryBlockComputationMacro.java @@ -55,7 +55,7 @@ public String getDescription() { @Override public boolean canApplyTo(Proof proof, ImmutableList goals, PosInOccurrence posInOcc) { - if (goals == null || goals.head() == null || goals.head().node() == null + if (goals == null || goals.isEmpty() || goals.head().node() == null || goals.head().node().parent() == null) { return false; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/informationflow/macros/StartAuxiliaryLoopComputationMacro.java b/key.core/src/main/java/de/uka/ilkd/key/informationflow/macros/StartAuxiliaryLoopComputationMacro.java index cd9f38083b4..e37ab3aefe9 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/informationflow/macros/StartAuxiliaryLoopComputationMacro.java +++ b/key.core/src/main/java/de/uka/ilkd/key/informationflow/macros/StartAuxiliaryLoopComputationMacro.java @@ -51,7 +51,7 @@ public String getDescription() { @Override public boolean canApplyTo(Proof proof, ImmutableList goals, PosInOccurrence posInOcc) { - if (goals == null || goals.head() == null || goals.head().node() == null + if (goals == null || goals.isEmpty() || goals.head().node() == null || goals.head().node().parent() == null) { return false; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/informationflow/macros/StartAuxiliaryMethodComputationMacro.java b/key.core/src/main/java/de/uka/ilkd/key/informationflow/macros/StartAuxiliaryMethodComputationMacro.java index 33dc44f19d0..c04e45bebe2 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/informationflow/macros/StartAuxiliaryMethodComputationMacro.java +++ b/key.core/src/main/java/de/uka/ilkd/key/informationflow/macros/StartAuxiliaryMethodComputationMacro.java @@ -52,7 +52,7 @@ public String getDescription() { @Override public boolean canApplyTo(Proof proof, ImmutableList goals, PosInOccurrence posInOcc) { - if (goals == null || goals.head() == null) { + if (goals == null || goals.isEmpty()) { return false; } if (posInOcc == null || posInOcc.subTerm() == null) { diff --git a/key.core/src/main/java/de/uka/ilkd/key/informationflow/po/IFProofObligationVars.java b/key.core/src/main/java/de/uka/ilkd/key/informationflow/po/IFProofObligationVars.java index 217093da97a..dc0912874df 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/informationflow/po/IFProofObligationVars.java +++ b/key.core/src/main/java/de/uka/ilkd/key/informationflow/po/IFProofObligationVars.java @@ -66,7 +66,12 @@ private void linkSymbExecVarsToCopies() { private void linkStateVarsToCopies(StateVars ifVars, StateVars seVars, Map map) { final Iterator ifVarsIt = ifVars.termList.iterator(); for (final Term symbTerm : seVars.termList) { - final Term ifTerm = ifVarsIt.next(); + final Term ifTerm; + if (ifVarsIt.hasNext()) { + ifTerm = ifVarsIt.next(); + } else { + ifTerm = null; + } if (symbTerm != null) { map.put(symbTerm, ifTerm); } diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/Taclet.java b/key.core/src/main/java/de/uka/ilkd/key/rule/Taclet.java index d930c46b70f..8eaaeef7c58 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/Taclet.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/Taclet.java @@ -494,11 +494,11 @@ public boolean equalsModProofIrrelevancy(Object o) { } else { ImmutableList if1 = ifSequent.asList(); ImmutableList if2 = t2.ifSequent.asList(); - while (if1.head() != null && if1.head().equalsModProofIrrelevancy(if2.head())) { + while (!if1.isEmpty() && !if2.isEmpty() && if1.head().equalsModProofIrrelevancy(if2.head())) { if1 = if1.tail(); if2 = if2.tail(); } - if (if1.head() != null || if2.head() != null) { + if (!if1.isEmpty() || !if2.isEmpty()) { return false; } } diff --git a/key.core/src/main/java/de/uka/ilkd/key/speclang/jml/translation/JMLSpecFactory.java b/key.core/src/main/java/de/uka/ilkd/key/speclang/jml/translation/JMLSpecFactory.java index f80ff858970..bd0a85fc4a8 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/speclang/jml/translation/JMLSpecFactory.java +++ b/key.core/src/main/java/de/uka/ilkd/key/speclang/jml/translation/JMLSpecFactory.java @@ -1169,8 +1169,9 @@ public Contract createJMLDependencyContract(KeYJavaType kjt, TextualJMLDepends t LabeledParserRuleContext dep = null; LocationVariable targetHeap = null; for (LocationVariable heap : HeapContext.getModHeaps(services, false)) { - dep = textualDep.getDepends(heap.name()).head(); - if (dep != null) { + ImmutableList depends = textualDep.getDepends(heap.name()); + if (!depends.isEmpty()) { + dep = textualDep.getDepends(heap.name()).head(); targetHeap = heap; break; } From 134458097b33bc89a4f7b2d661cfeaac5968c335 Mon Sep 17 00:00:00 2001 From: Florian Lanzinger Date: Thu, 2 May 2024 11:25:30 +0200 Subject: [PATCH 37/37] Fix formatting --- .../nparser/builder/DeclarationBuilder.java | 1 - .../java/de/uka/ilkd/key/rule/Taclet.java | 3 +- .../key/gui/actions/SendFeedbackAction.java | 1 - .../util/collection/IdentityHashSet.java | 4 +-- .../org/key_project/util/collection/Pair.java | 4 +-- .../org/key_project/util/java/ArrayUtil.java | 9 +++--- .../key_project/util/java/CollectionUtil.java | 24 ++++++++++----- .../org/key_project/util/java/IOUtil.java | 4 +-- .../util/collection/TestImmutables.java | 27 +++++++++++------ .../collection/TestSLListOfString.java | 8 +++-- .../util/testcase/java/ArrayUtilTest.java | 29 ++++++++++++------- .../testcase/java/CollectionUtilTest.java | 2 +- .../util/testcase/java/IOUtilTest.java | 7 +++-- .../util/testcase/java/NumberUtilTest.java | 1 - .../util/testcase/java/StringUtilTest.java | 2 +- .../util/testcase/java/XMLUtilTest.java | 1 - 16 files changed, 77 insertions(+), 50 deletions(-) diff --git a/key.core/src/main/java/de/uka/ilkd/key/nparser/builder/DeclarationBuilder.java b/key.core/src/main/java/de/uka/ilkd/key/nparser/builder/DeclarationBuilder.java index 10e7ce6f636..048588c7717 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/nparser/builder/DeclarationBuilder.java +++ b/key.core/src/main/java/de/uka/ilkd/key/nparser/builder/DeclarationBuilder.java @@ -22,7 +22,6 @@ import org.key_project.logic.Name; import org.key_project.logic.Named; import org.key_project.logic.sort.Sort; -import org.key_project.util.collection.DefaultImmutableSet; import org.key_project.util.collection.ImmutableSet; import org.key_project.util.collection.Immutables; diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/Taclet.java b/key.core/src/main/java/de/uka/ilkd/key/rule/Taclet.java index 8eaaeef7c58..2d3ca83afb4 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/Taclet.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/Taclet.java @@ -494,7 +494,8 @@ public boolean equalsModProofIrrelevancy(Object o) { } else { ImmutableList if1 = ifSequent.asList(); ImmutableList if2 = t2.ifSequent.asList(); - while (!if1.isEmpty() && !if2.isEmpty() && if1.head().equalsModProofIrrelevancy(if2.head())) { + while (!if1.isEmpty() && !if2.isEmpty() + && if1.head().equalsModProofIrrelevancy(if2.head())) { if1 = if1.tail(); if2 = if2.tail(); } diff --git a/key.ui/src/main/java/de/uka/ilkd/key/gui/actions/SendFeedbackAction.java b/key.ui/src/main/java/de/uka/ilkd/key/gui/actions/SendFeedbackAction.java index 74fbc397dd9..59a6e71cee5 100644 --- a/key.ui/src/main/java/de/uka/ilkd/key/gui/actions/SendFeedbackAction.java +++ b/key.ui/src/main/java/de/uka/ilkd/key/gui/actions/SendFeedbackAction.java @@ -13,7 +13,6 @@ import java.nio.file.Files; import java.util.LinkedList; import java.util.List; -import java.util.Optional; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; import javax.swing.*; diff --git a/key.util/src/main/java/org/key_project/util/collection/IdentityHashSet.java b/key.util/src/main/java/org/key_project/util/collection/IdentityHashSet.java index 9fbcfe44e09..f68a9b8a6b9 100644 --- a/key.util/src/main/java/org/key_project/util/collection/IdentityHashSet.java +++ b/key.util/src/main/java/org/key_project/util/collection/IdentityHashSet.java @@ -59,14 +59,14 @@ public Iterator iterator() { } // see https://eisop.github.io/cf/manual/manual.html#nullness-collection-toarray - @SuppressWarnings({"nullness","override.return.invalid"}) + @SuppressWarnings({ "nullness", "override.return.invalid" }) @Override public @Nullable Object[] toArray() { return innerMap.keySet().toArray(); } // see https://eisop.github.io/cf/manual/manual.html#nullness-collection-toarray - @SuppressWarnings({"nullness","override.return.invalid"}) + @SuppressWarnings({ "nullness", "override.return.invalid" }) @Override public T[] toArray(T[] a) { return innerMap.keySet().toArray(a); diff --git a/key.util/src/main/java/org/key_project/util/collection/Pair.java b/key.util/src/main/java/org/key_project/util/collection/Pair.java index d2bf55fdbff..29a7d3f9393 100644 --- a/key.util/src/main/java/org/key_project/util/collection/Pair.java +++ b/key.util/src/main/java/org/key_project/util/collection/Pair.java @@ -3,13 +3,13 @@ * SPDX-License-Identifier: GPL-2.0-only */ package org.key_project.util.collection; -import org.jspecify.annotations.Nullable; - import java.util.Collection; import java.util.Map; import java.util.Objects; import java.util.Set; +import org.jspecify.annotations.Nullable; + /** * Simple value object to hold two values. * diff --git a/key.util/src/main/java/org/key_project/util/java/ArrayUtil.java b/key.util/src/main/java/org/key_project/util/java/ArrayUtil.java index 4c17c60ebc0..c1fe336dd4d 100644 --- a/key.util/src/main/java/org/key_project/util/java/ArrayUtil.java +++ b/key.util/src/main/java/org/key_project/util/java/ArrayUtil.java @@ -61,8 +61,8 @@ private ArrayUtil() { @SuppressWarnings("unchecked") public static T[] addAll(T[] array, T[] toAdd) { T[] result = - (T[]) java.lang.reflect.Array.newInstance(getComponentType(array), - array.length + toAdd.length); + (T[]) java.lang.reflect.Array.newInstance(getComponentType(array), + array.length + toAdd.length); System.arraycopy(array, 0, result, 0, array.length); System.arraycopy(toAdd, 0, result, array.length, toAdd.length); return result; @@ -91,9 +91,10 @@ private ArrayUtil() { * @throws IllegalArgumentException Both parameters are {@code null}. */ @SuppressWarnings("unchecked") - public static T[] addAll(T[] array, T[] toAdd, Class newArrayType) { + public static T[] addAll(T[] array, T[] toAdd, + Class newArrayType) { T[] result = (T[]) java.lang.reflect.Array.newInstance(newArrayType, - array.length + toAdd.length); + array.length + toAdd.length); System.arraycopy(array, 0, result, 0, array.length); System.arraycopy(toAdd, 0, result, array.length, toAdd.length); return result; diff --git a/key.util/src/main/java/org/key_project/util/java/CollectionUtil.java b/key.util/src/main/java/org/key_project/util/java/CollectionUtil.java index b1872dace0b..baa70c6c94f 100644 --- a/key.util/src/main/java/org/key_project/util/java/CollectionUtil.java +++ b/key.util/src/main/java/org/key_project/util/java/CollectionUtil.java @@ -105,7 +105,8 @@ public static void addAll(Collection collection, Iterable iterable) { * @return {@code true} if at least one element was removed, {@code false} if the * {@link Collection} was not modified. */ - public static boolean removeComplete(Collection collection, T toRemove) { + public static boolean removeComplete(Collection collection, + T toRemove) { Iterator iter = collection.iterator(); boolean changed = false; while (iter.hasNext()) { @@ -124,7 +125,8 @@ public static void addAll(Collection collection, Iterable iterable) { * @param filter The {@link IFilter} to use. * @return The elements accepted by the given {@link Predicate}. */ - public static List searchAll(Iterable iterable, Predicate filter) { + public static List searchAll(Iterable iterable, + Predicate filter) { List result = new ArrayList<>(); for (T element : iterable) { if (filter.test(element)) { @@ -141,7 +143,8 @@ public static void addAll(Collection collection, Iterable iterable) { * @param filter The filter to select an element. * @return The found element or {@code null} if no element was found. */ - public static @Nullable T search(Iterable iterable, Predicate filter) { + public static @Nullable T search(Iterable iterable, + Predicate filter) { T result = null; Iterator iter = iterable.iterator(); while (result == null && iter.hasNext()) { @@ -161,7 +164,8 @@ public static void addAll(Collection collection, Iterable iterable) { * @param filter The filter to select an element. * @return The found element or {@code null} if no element was found. */ - public static @Nullable T searchAndRemove(Iterable iterable, Predicate filter) { + public static @Nullable T searchAndRemove(Iterable iterable, + Predicate filter) { T result = null; Iterator iter = iterable.iterator(); while (result == null && iter.hasNext()) { @@ -221,7 +225,8 @@ public static void addAll(Collection collection, Iterable iterable) { * @param filter The {@link IFilter} to select elements. * @return The number of elements selected by the {@link IFilter} in the given {@link Iterable}. */ - public static int count(Iterable iterable, Predicate filter) { + public static int count(Iterable iterable, + Predicate filter) { int count = 0; for (T element : iterable) { if (filter.test(element)) { @@ -245,9 +250,11 @@ public static void addAll(Collection collection, Iterable iterable) { * {@link Collection}s are different. */ @SuppressWarnings("nullness:argument.type.incompatible") - // Checker Framework conservatively disallows passing null to Collection.remove, but if we have a collection of type + // Checker Framework conservatively disallows passing null to Collection.remove, but if we have + // a collection of type // Collection<@Nullable C>, it's probably fine. - public static boolean containsSame(Collection first, Collection second) { + public static boolean containsSame(Collection first, + Collection second) { if (first.size() == second.size()) { Collection firstCopy = new LinkedList<>(first); boolean same = true; @@ -286,7 +293,8 @@ public static void addAll(Collection collection, Iterable iterable) { * @param toInsert The element to insert. * @param comparator The {@link Comparator} to use. */ - public static void binaryInsert(List list, T toInsert, Comparator comparator) { + public static void binaryInsert(List list, T toInsert, + Comparator comparator) { if (list.isEmpty()) { list.add(toInsert); } else { diff --git a/key.util/src/main/java/org/key_project/util/java/IOUtil.java b/key.util/src/main/java/org/key_project/util/java/IOUtil.java index 1750224328a..65578b4e82a 100644 --- a/key.util/src/main/java/org/key_project/util/java/IOUtil.java +++ b/key.util/src/main/java/org/key_project/util/java/IOUtil.java @@ -16,7 +16,6 @@ import java.util.zip.ZipException; import java.util.zip.ZipInputStream; -import org.checkerframework.checker.nullness.qual.PolyNull; import org.jspecify.annotations.NonNull; import org.jspecify.annotations.Nullable; @@ -595,7 +594,8 @@ public static boolean contains(Iterable parents, File child) { */ public static boolean contains(File parent, File child) { boolean contains = false; - @Nullable File current = child; + @Nullable + File current = child; while (!contains && current != null) { if (parent.equals(current)) { contains = true; diff --git a/key.util/src/test/java/org/key_project/util/collection/TestImmutables.java b/key.util/src/test/java/org/key_project/util/collection/TestImmutables.java index c0a2283e633..e97c6d53814 100644 --- a/key.util/src/test/java/org/key_project/util/collection/TestImmutables.java +++ b/key.util/src/test/java/org/key_project/util/collection/TestImmutables.java @@ -35,13 +35,16 @@ public void testRemoveDuplicatesLarge() { @Test public void testRemoveDuplicates() { - @Nullable String[][] a = { { "a", "b", "a", "c", "d", "d", "a", "e" }, { null, "a", null }, + @Nullable + String[][] a = { { "a", "b", "a", "c", "d", "d", "a", "e" }, { null, "a", null }, { "1", "1", "1", "1", "1" } }; - @Nullable String[][] expected = { { "a", "b", "c", "d", "e" }, { null, "a" }, { "1" } }; + @Nullable + String[][] expected = { { "a", "b", "c", "d", "e" }, { null, "a" }, { "1" } }; for (int i = 0; i < a.length; i++) { - ImmutableList<@Nullable String> l = ImmutableSLList.<@Nullable String>nil().prepend(a[i]).reverse(); + ImmutableList<@Nullable String> l = + ImmutableSLList.<@Nullable String>nil().prepend(a[i]).reverse(); assertFalse(Immutables.isDuplicateFree(l)); @@ -66,18 +69,24 @@ public void testRemoveDuplicatesIdentical() { @Test public void testIsDuplicateFree() { - @Nullable String[][] a = { { "a", "b", "c", "d", "e" }, {}, { "a" }, { null }, { null, "a" } }; + @Nullable + String[][] a = { { "a", "b", "c", "d", "e" }, {}, { "a" }, { null }, { null, "a" } }; - for (@Nullable String[] strings : a) { - ImmutableList<@Nullable String> l = ImmutableSLList.<@Nullable String>nil().prepend(strings); + for (@Nullable + String[] strings : a) { + ImmutableList<@Nullable String> l = + ImmutableSLList.<@Nullable String>nil().prepend(strings); assertTrue(Immutables.isDuplicateFree(l)); } - @Nullable String[][] b = { { "a", "a" }, { "a", "b", "c", "d", "a" }, { "a", "b", "a", "d", "e" }, + @Nullable + String[][] b = { { "a", "a" }, { "a", "b", "c", "d", "a" }, { "a", "b", "a", "d", "e" }, { "a", "b", "d", "d", "e" }, { "a", "b", "c", "d", "d" }, { null, "a", null } }; - for (@Nullable String[] strings : b) { - ImmutableList<@Nullable String> l = ImmutableSLList.<@Nullable String>nil().prepend(strings); + for (@Nullable + String[] strings : b) { + ImmutableList<@Nullable String> l = + ImmutableSLList.<@Nullable String>nil().prepend(strings); assertFalse(Immutables.isDuplicateFree(l)); } diff --git a/key.util/src/test/java/org/key_project/util/testcase/collection/TestSLListOfString.java b/key.util/src/test/java/org/key_project/util/testcase/collection/TestSLListOfString.java index 12838a8b85a..e621abd3c76 100644 --- a/key.util/src/test/java/org/key_project/util/testcase/collection/TestSLListOfString.java +++ b/key.util/src/test/java/org/key_project/util/testcase/collection/TestSLListOfString.java @@ -6,10 +6,10 @@ import java.util.Iterator; import java.util.Objects; -import org.jspecify.annotations.Nullable; import org.key_project.util.collection.ImmutableList; import org.key_project.util.collection.ImmutableSLList; +import org.jspecify.annotations.Nullable; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.slf4j.Logger; @@ -42,8 +42,10 @@ public void setUp() { b = ImmutableSLList.nil().prepend("B").prepend("A"); c = ImmutableSLList.nil().prepend("D").prepend("C").prepend("B").prepend("A"); d = ImmutableSLList.nil().prepend("A").prepend("B").prepend("A"); - e = ImmutableSLList.<@Nullable String>nil().prepend((String) null).prepend("B").prepend("A"); - e1 = ImmutableSLList.<@Nullable String>nil().prepend((String) null).prepend("B").prepend("A"); + e = ImmutableSLList.<@Nullable String>nil().prepend((String) null).prepend("B") + .prepend("A"); + e1 = ImmutableSLList.<@Nullable String>nil().prepend((String) null).prepend("B") + .prepend("A"); } // tests prepend and implicitly iterator, size diff --git a/key.util/src/test/java/org/key_project/util/testcase/java/ArrayUtilTest.java b/key.util/src/test/java/org/key_project/util/testcase/java/ArrayUtilTest.java index 51c1d094e05..d0122cb7ed5 100644 --- a/key.util/src/test/java/org/key_project/util/testcase/java/ArrayUtilTest.java +++ b/key.util/src/test/java/org/key_project/util/testcase/java/ArrayUtilTest.java @@ -5,10 +5,10 @@ import java.util.function.Predicate; -import org.jspecify.annotations.Nullable; import org.key_project.util.java.ArrayUtil; import org.key_project.util.java.StringUtil; +import org.jspecify.annotations.Nullable; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.*; @@ -21,7 +21,8 @@ public class ArrayUtilTest { @Test public void testInsert() { - @Nullable String[] array = { "A", "B", "C" }; + @Nullable + String[] array = { "A", "B", "C" }; // Test possible indices assertArray(ArrayUtil.insert(array, "X", 0), "X", "A", "B", "C"); assertArray(ArrayUtil.insert(array, "X", 1), "A", "X", "B", "C"); @@ -56,7 +57,8 @@ public void testInsert() { */ @Test public void testSearch() { - @Nullable String[] array = { "A", "B", "C", "D" }; + @Nullable + String[] array = { "A", "B", "C", "D" }; assertEquals("A", ArrayUtil.<@Nullable String>search(array, "A"::equals)); assertEquals("B", ArrayUtil.<@Nullable String>search(array, "B"::equals)); assertEquals("C", ArrayUtil.<@Nullable String>search(array, "C"::equals)); @@ -127,7 +129,8 @@ public void testToString_Object() { @Test public void testRemove() { // Test remove on array - @Nullable String[] array = new @Nullable String[] { "A", "B", "C", null, "D", null, null, "C", "A" }; + @Nullable + String[] array = new @Nullable String[] { "A", "B", "C", null, "D", null, null, "C", "A" }; array = ArrayUtil.remove(array, "B"); // Remove B assertArrayEquals(array, "A", "C", null, "D", null, null, "C", "A"); array = ArrayUtil.remove(array, "B"); // Remove B again @@ -168,7 +171,8 @@ protected void assertArrayEquals(T[] array, T... expectedValues) { public void testAddAll() { String[] first = new String[] { "A", "B", "C" }; String[] second = new String[] { "D", "E" }; - @Nullable String[] combined = ArrayUtil.addAll(first, second); + @Nullable + String[] combined = ArrayUtil.addAll(first, second); assertEquals(5, combined.length); assertEquals("A", combined[0]); assertEquals("B", combined[1]); @@ -184,7 +188,8 @@ public void testAddAll() { public void testAddAll_newType() { String[] first = new String[] { "A", "B", "C" }; String[] second = new String[] { "D", "E" }; - @Nullable Object[] combined = ArrayUtil.addAll(first, second, Object.class); + @Nullable + Object[] combined = ArrayUtil.addAll(first, second, Object.class); assertEquals(Object.class, combined.getClass().getComponentType()); assertEquals(5, combined.length); assertEquals("A", combined[0]); @@ -237,8 +242,10 @@ public void testAdd_int() { @Test public void testAdd_Object() { // Test empty array - @Nullable String[] array = new String[] {}; - @Nullable String[] result = ArrayUtil.add(array, "A"); + @Nullable + String[] array = new String[] {}; + @Nullable + String[] result = ArrayUtil.add(array, "A"); assertNotNull(result); assertEquals(1, result.length); assertEquals("A", result[0]); @@ -288,7 +295,8 @@ public void testContains() { assertTrue(ArrayUtil.contains(array, "B")); assertTrue(ArrayUtil.contains(array, "C")); assertFalse(ArrayUtil.contains(array, "D")); - @Nullable String[] arrayWithNull = { "A", "B", null, "D" }; + @Nullable + String[] arrayWithNull = { "A", "B", null, "D" }; assertTrue(ArrayUtil.contains(arrayWithNull, null)); assertTrue(ArrayUtil.contains(arrayWithNull, "A")); assertTrue(ArrayUtil.contains(arrayWithNull, "B")); @@ -314,7 +322,8 @@ public void testIndexOf() { assertEquals(1, ArrayUtil.indexOf(array, "B")); assertEquals(2, ArrayUtil.indexOf(array, "C")); assertEquals(-1, ArrayUtil.indexOf(array, "D")); - @Nullable String[] arrayWithNull = { "A", "B", null, "D" }; + @Nullable + String[] arrayWithNull = { "A", "B", null, "D" }; assertEquals(2, ArrayUtil.indexOf(arrayWithNull, null)); assertEquals(0, ArrayUtil.indexOf(arrayWithNull, "A")); assertEquals(1, ArrayUtil.indexOf(arrayWithNull, "B")); diff --git a/key.util/src/test/java/org/key_project/util/testcase/java/CollectionUtilTest.java b/key.util/src/test/java/org/key_project/util/testcase/java/CollectionUtilTest.java index 409309555a4..c38f12143c1 100644 --- a/key.util/src/test/java/org/key_project/util/testcase/java/CollectionUtilTest.java +++ b/key.util/src/test/java/org/key_project/util/testcase/java/CollectionUtilTest.java @@ -6,10 +6,10 @@ import java.util.*; import java.util.function.Predicate; -import org.jspecify.annotations.Nullable; import org.key_project.util.java.CollectionUtil; import org.key_project.util.java.IFilterWithException; +import org.jspecify.annotations.Nullable; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.*; diff --git a/key.util/src/test/java/org/key_project/util/testcase/java/IOUtilTest.java b/key.util/src/test/java/org/key_project/util/testcase/java/IOUtilTest.java index a9863593c60..920fa516e97 100644 --- a/key.util/src/test/java/org/key_project/util/testcase/java/IOUtilTest.java +++ b/key.util/src/test/java/org/key_project/util/testcase/java/IOUtilTest.java @@ -14,13 +14,13 @@ import javax.xml.parsers.SAXParser; import javax.xml.parsers.SAXParserFactory; -import org.jspecify.annotations.Nullable; import org.key_project.util.helper.HelperClassForUtilityTests; import org.key_project.util.java.IOUtil; import org.key_project.util.java.IOUtil.IFileVisitor; import org.key_project.util.java.IOUtil.LineInformation; import org.key_project.util.java.XMLUtil; +import org.jspecify.annotations.Nullable; import org.junit.jupiter.api.Test; import org.xml.sax.Attributes; import org.xml.sax.SAXException; @@ -585,7 +585,8 @@ protected void assertLineInformation(String newLine, String... textLines) throws */ protected void assertLineInformation(String text, LineInformation... expectedInfos) throws IOException { - LineInformation[] result = IOUtil.computeLineInformation(new ByteArrayInputStream(text.getBytes(StandardCharsets.UTF_8))); + LineInformation[] result = IOUtil.computeLineInformation( + new ByteArrayInputStream(text.getBytes(StandardCharsets.UTF_8))); assertNotNull(result, text); assertEquals(expectedInfos.length, result.length, text); for (int i = 0; i < expectedInfos.length; i++) { @@ -743,7 +744,7 @@ public void testReadFrom_InputStream() { protected void doTestReadFrom(String text) throws IOException { assertEquals(text, - IOUtil.readFrom(new ByteArrayInputStream(text.getBytes(StandardCharsets.UTF_8)))); + IOUtil.readFrom(new ByteArrayInputStream(text.getBytes(StandardCharsets.UTF_8)))); } /** diff --git a/key.util/src/test/java/org/key_project/util/testcase/java/NumberUtilTest.java b/key.util/src/test/java/org/key_project/util/testcase/java/NumberUtilTest.java index 836fa8b26c2..e5fbdba9bc2 100644 --- a/key.util/src/test/java/org/key_project/util/testcase/java/NumberUtilTest.java +++ b/key.util/src/test/java/org/key_project/util/testcase/java/NumberUtilTest.java @@ -8,7 +8,6 @@ import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.fail; /** * Tests for {@link NumberUtil}. diff --git a/key.util/src/test/java/org/key_project/util/testcase/java/StringUtilTest.java b/key.util/src/test/java/org/key_project/util/testcase/java/StringUtilTest.java index 249055693f5..6e165ac6aa6 100644 --- a/key.util/src/test/java/org/key_project/util/testcase/java/StringUtilTest.java +++ b/key.util/src/test/java/org/key_project/util/testcase/java/StringUtilTest.java @@ -5,9 +5,9 @@ import java.util.Comparator; -import org.jspecify.annotations.Nullable; import org.key_project.util.java.StringUtil; +import org.jspecify.annotations.Nullable; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.*; diff --git a/key.util/src/test/java/org/key_project/util/testcase/java/XMLUtilTest.java b/key.util/src/test/java/org/key_project/util/testcase/java/XMLUtilTest.java index 5fa925e12b6..d2ef7105106 100644 --- a/key.util/src/test/java/org/key_project/util/testcase/java/XMLUtilTest.java +++ b/key.util/src/test/java/org/key_project/util/testcase/java/XMLUtilTest.java @@ -13,7 +13,6 @@ import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNull; /** * Tests for {@link XMLUtil}.