Repository: apache/jena (java)

Issue:
Update jena-text to use Lucene in a Java21 compatible way.
The upgrade of lucene 9.10. -> 9.11.0 #2532 causes the build output below.

Both these warnings need to be addressed by moving the jena-text code forward to the now-preferred Lucene way of doing things.

Building with a Java21 JDK, for release Java17 output:

Lucene 9.10.0:
```
[INFO] Running org.apache.jena.query.text.assembler.TestTextDatasetAssembler
Jun 10, 2024 11:47:38 AM org.apache.lucene.store.MemorySegmentIndexInputProvider <init>
INFO: Using MemorySegmentIndexInput with Java 21 or later; to disable start with -Dorg.apache.lucene.store.MMapDirectory.enableMemorySegments=false
```


Lucene 9.11.0:
```
[INFO] Running org.apache.jena.query.text.assembler.TestTextDatasetAssembler
WARNING: A restricted method in java.lang.foreign.Linker has been called
WARNING: java.lang.foreign.Linker::downcallHandle has been called by the unnamed module
WARNING: Use --enable-native-access=ALL-UNNAMED to avoid a warning for this module

Jun 10, 2024 11:45:22 AM org.apache.lucene.store.MemorySegmentIndexInputProvider <init>
INFO: Using MemorySegmentIndexInput and native madvise support with Java 21 or later; to disable start with -Dorg.apache.lucene.store.MMapDirectory.enableMemorySegments=false
```


### Are you interested in contributing a pull request for this task?

None

Pull request:
Warnings lucene
GitHub issue resolved #2533

Pull request Description:

Add different build arguments based on the running JVM version to minimize lucene warnings during build
This is based on how tests are being run in Apache Lucene (in gradle) where they check for java version and add args if >=21
but translated-ish to maven.

https://github.com/apache/lucene/blob/1faf33a02afd610c90ffa8685b1675f9d1c24b0e/gradle/testing/defaults-tests.gradle#L131

----

 - [ ] Tests are included.
 - [ ] Documentation change and updates are provided for the [Apache Jena website](https://github.com/apache/jena-site/)
 - [ ] Commits have been squashed to remove intermediate development commit messages.
 - [ ] Key commit messages start with the issue number (GH-xxxx)

By submitting this pull request, I acknowledge that I am making a contribution to the Apache Software Foundation under the terms and conditions of the [Contributor's Agreement](https://www.apache.org/licenses/contributor-agreements.html).

----

See the [Apache Jena "Contributing" guide](https://github.com/apache/jena/blob/main/CONTRIBUTING.md).


Patch:
diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml
index d76c3044e1..266e3e2bb9 100644
--- a/.github/workflows/maven.yml
+++ b/.github/workflows/maven.yml
@@ -21,13 +21,14 @@ jobs:
       fail-fast: false
       matrix:
         os: [ubuntu-latest]
+        java_version: ['17', '21']
 
     steps:
     - uses: actions/checkout@v4
-    - name: Set up JDK 17
+    - name: Set up JDK ${{ matrix.java_version }}
       uses: actions/setup-java@v4
       with:
         distribution: 'temurin'
-        java-version: '17'
+        java-version: ${{ matrix.java_version }}
     - name: Build with Maven
       run: mvn -B --file pom.xml -Dmaven.javadoc.skip=true install
diff --git a/jena-core/src/main/java/org/apache/jena/datatypes/TypeMapper.java b/jena-core/src/main/java/org/apache/jena/datatypes/TypeMapper.java
index 5dd07fba12..821df17ae5 100644
--- a/jena-core/src/main/java/org/apache/jena/datatypes/TypeMapper.java
+++ b/jena-core/src/main/java/org/apache/jena/datatypes/TypeMapper.java
@@ -126,18 +126,16 @@ public class TypeMapper {
             // Plain literal
             return null;
         }
-        RDFDatatype dtype = uriToDT.get(uri);
-        if (dtype == null) {
+        return uriToDT.computeIfAbsent(uri, u -> {
             // Unknown datatype
             if (JenaParameters.enableSilentAcceptanceOfUnknownDatatypes) {
-                dtype = new BaseDatatype(uri);
-                registerDatatype(dtype);
+                // No need to update classToDT because BaseDatatype.getJavaClass is always null
+                return new BaseDatatype(u);
             } else {
                 throw new DatatypeFormatException(
                     "Attempted to created typed literal using an unknown datatype - " + uri);
             }
-        }
-        return dtype;
+        });
     }
 
     /**
@@ -183,6 +181,9 @@ public class TypeMapper {
 
     /**
      * Register a new datatype
+     * This will overwrite any existing registration for this datatype IRI.
+     * Comparisons of literals with different datatype instances will fail, so be careful
+     * if you are using this outside of initialization code.
      */
     public void registerDatatype(final RDFDatatype type) {
         uriToDT.put(type.getURI(), type);
@@ -194,6 +195,10 @@ public class TypeMapper {
 
     /**
      * Remove a datatype registration.
+     * <p>
+     * WARNING: This method may cause unexpected behavior if the datatype is still in use.
+     * If you unregister a datatype that is still used somewhere on the heap, literal comparisons with
+     * that datatype will fail.
      */
     public void unregisterDatatype(final RDFDatatype type) {
         uriToDT.remove(type.getURI());
diff --git a/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/validation/ValidationState.java b/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/validation/ValidationState.java
index 9978270f2d..0e7b0a384a 100644
--- a/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/validation/ValidationState.java
+++ b/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/validation/ValidationState.java
@@ -28,6 +28,8 @@ import org.apache.jena.ext.xerces.xni.NamespaceContext;
 /**
  * Implementation of the ValidationContext interface. Used to establish an
  * environment for simple type validation.
+ * <p>
+ * This class is not thread-safe.
  *
  * {@literal @xerces.internal}
  *
@@ -50,9 +52,10 @@ public class ValidationState implements ValidationContext {
     private SymbolTable fSymbolTable            = null;
     private Locale fLocale                      = null;
 
-    //REVISIT: Should replace with a lighter structure.
-    private final HashMap fIdTable    = new HashMap();
-    private final HashMap fIdRefTable = new HashMap();
+    // REVISIT: Should replace with a lighter structure.
+    // These tables are initialized only on demand to avoid unneeded allocations.
+    private HashMap fIdTable    = null;
+    private HashMap fIdRefTable = null;
     private final static Object fNullValue = new Object();
 
     //
@@ -91,11 +94,12 @@ public class ValidationState implements ValidationContext {
      * otherwise return the first IDREF value without a matching ID value.
      */
     public String checkIDRefID () {
+        if (fIdRefTable == null) return null;
         Iterator iter = fIdRefTable.keySet().iterator();
         String key;
         while (iter.hasNext()) {
             key = (String) iter.next();
-            if (!fIdTable.containsKey(key)) {
+            if (fIdTable == null || !fIdTable.containsKey(key)) {
                   return key;
             }
         }
@@ -106,8 +110,8 @@ public class ValidationState implements ValidationContext {
         fExtraChecking = true;
         fFacetChecking = true;
         fNamespaces = true;
-        fIdTable.clear();
-        fIdRefTable.clear();
+        fIdTable = null;
+        fIdRefTable = null;
         fEntityState = null;
         fNamespaceContext = null;
         fSymbolTable = null;
@@ -120,8 +124,8 @@ public class ValidationState implements ValidationContext {
      * the two tables.
      */
     public void resetIDTables() {
-        fIdTable.clear();
-        fIdRefTable.clear();
+        fIdTable = null;
+        fIdRefTable = null;
     }
 
     //
@@ -169,16 +173,25 @@ public class ValidationState implements ValidationContext {
     // id
     @Override
     public boolean isIdDeclared(String name) {
+        if (fIdTable == null) {
+            return false;
+        }
         return fIdTable.containsKey(name);
     }
     @Override
     public void addId(String name) {
+        if (fIdTable == null) {
+            fIdTable = new HashMap();
+        }
         fIdTable.put(name, fNullValue);
     }
 
     // idref
     @Override
     public void addIdRef(String name) {
+        if (fIdRefTable == null) {
+            fIdRefTable = new HashMap();
+        }
         fIdRefTable.put(name, fNullValue);
     }
     // get symbols
diff --git a/jena-ontapi/src/main/java/org/apache/jena/ontapi/impl/OntGraphModelImpl.java b/jena-ontapi/src/main/java/org/apache/jena/ontapi/impl/OntGraphModelImpl.java
index 588fa3e26b..ad7bae3c94 100644
--- a/jena-ontapi/src/main/java/org/apache/jena/ontapi/impl/OntGraphModelImpl.java
+++ b/jena-ontapi/src/main/java/org/apache/jena/ontapi/impl/OntGraphModelImpl.java
@@ -965,8 +965,10 @@ public class OntGraphModelImpl extends ModelCom implements OntModel, OntEnhGraph
 
     @Override
     public OntDisjoint.Classes createDisjointClasses(Collection<OntClass> classes) {
+        if (classes.isEmpty()) {
+            throw new IllegalArgumentException("Empty list is specified");
+        }
         checkType(OntDisjoint.Classes.class);
-        checkType(OntClass.IntersectionOf.class);
         return checkCreate(model ->
                 OntDisjointImpl.createDisjointClasses(model, classes.stream()), OntDisjoint.Classes.class
         );
@@ -974,6 +976,9 @@ public class OntGraphModelImpl extends ModelCom implements OntModel, OntEnhGraph
 
     @Override
     public OntDisjoint.Individuals createDifferentIndividuals(Collection<OntIndividual> individuals) {
+        if (individuals.isEmpty()) {
+            throw new IllegalArgumentException("Empty list is specified");
+        }
         checkType(OntDisjoint.Individuals.class);
         return checkCreate(model ->
                 OntDisjointImpl.createDifferentIndividuals(model, individuals.stream()), OntDisjoint.Individuals.class
@@ -982,6 +987,9 @@ public class OntGraphModelImpl extends ModelCom implements OntModel, OntEnhGraph
 
     @Override
     public OntDisjoint.ObjectProperties createDisjointObjectProperties(Collection<OntObjectProperty> properties) {
+        if (properties.isEmpty()) {
+            throw new IllegalArgumentException("Empty list is specified");
+        }
         checkType(OntDisjoint.ObjectProperties.class);
         return checkCreate(model ->
                 OntDisjointImpl.createDisjointObjectProperties(model, properties.stream()), OntDisjoint.ObjectProperties.class
@@ -990,6 +998,9 @@ public class OntGraphModelImpl extends ModelCom implements OntModel, OntEnhGraph
 
     @Override
     public OntDisjoint.DataProperties createDisjointDataProperties(Collection<OntDataProperty> properties) {
+        if (properties.isEmpty()) {
+            throw new IllegalArgumentException("Empty list is specified");
+        }
         checkType(OntDisjoint.DataProperties.class);
         return checkCreate(model ->
                 OntDisjointImpl.createDisjointDataProperties(model, properties.stream()), OntDisjoint.DataProperties.class
diff --git a/jena-ontapi/src/main/java/org/apache/jena/ontapi/impl/factories/OWL2ObjectFactories.java b/jena-ontapi/src/main/java/org/apache/jena/ontapi/impl/factories/OWL2ObjectFactories.java
index d79b8ea209..fe4daf9772 100644
--- a/jena-ontapi/src/main/java/org/apache/jena/ontapi/impl/factories/OWL2ObjectFactories.java
+++ b/jena-ontapi/src/main/java/org/apache/jena/ontapi/impl/factories/OWL2ObjectFactories.java
@@ -785,16 +785,16 @@ public final class OWL2ObjectFactories {
             OntFacetRestriction.LangRange.class
     );
 
-    public static final EnhNodeFactory CLASSES_DISJOINT = OntDisjoints.createDisjointClassesFactory(0);
+    public static final EnhNodeFactory CLASSES_DISJOINT = OntDisjoints.createDisjointClassesFactory(1);
     public static final EnhNodeFactory EL_CLASSES_DISJOINT = OntDisjoints.createDisjointClassesFactory(2);
     public static final EnhNodeFactory QL_RL_CLASSES_DISJOINT = OntDisjoints.createQLRLDisjointClassesFactory();
     public static final Function<OntConfig, EnhNodeFactory> DIFFERENT_INDIVIDUALS_DISJOINT =
             OntDisjoints::createDLFullDifferentIndividualsFactory;
     public static final EnhNodeFactory EL_QL_RL_DIFFERENT_INDIVIDUALS_DISJOINT =
             OntDisjoints.createELQLRLDifferentIndividualsFactory();
-    public static final EnhNodeFactory OBJECT_PROPERTIES_DISJOINT = OntDisjoints.createDisjointObjectPropertiesFactory(0);
+    public static final EnhNodeFactory OBJECT_PROPERTIES_DISJOINT = OntDisjoints.createDisjointObjectPropertiesFactory(1);
     public static final EnhNodeFactory QL_RL_OBJECT_PROPERTIES_DISJOINT = OntDisjoints.createDisjointObjectPropertiesFactory(2);
-    public static final EnhNodeFactory DATA_PROPERTIES_DISJOINT = OntDisjoints.createDisjointDataPropertiesFactory(0);
+    public static final EnhNodeFactory DATA_PROPERTIES_DISJOINT = OntDisjoints.createDisjointDataPropertiesFactory(1);
     public static final EnhNodeFactory QL_RL_DATA_PROPERTIES_DISJOINT = OntDisjoints.createDisjointDataPropertiesFactory(2);
 
     public static final EnhNodeFactory ANY_PROPERTIES_DISJOINT = OntEnhNodeFactories.createFrom(
diff --git a/jena-ontapi/src/main/java/org/apache/jena/ontapi/impl/factories/OntDisjoints.java b/jena-ontapi/src/main/java/org/apache/jena/ontapi/impl/factories/OntDisjoints.java
index 8b6561a3be..421c74541b 100644
--- a/jena-ontapi/src/main/java/org/apache/jena/ontapi/impl/factories/OntDisjoints.java
+++ b/jena-ontapi/src/main/java/org/apache/jena/ontapi/impl/factories/OntDisjoints.java
@@ -68,7 +68,7 @@ final class OntDisjoints {
                 OWL2.AllDifferent,
                 OntIndividual.class,
                 it -> true,
-                0,
+                1,
                 predicates
         );
     }
diff --git a/jena-text/pom.xml b/jena-text/pom.xml
index 1382fabe7a..f389fc9153 100644
--- a/jena-text/pom.xml
+++ b/jena-text/pom.xml
@@ -27,8 +27,20 @@
     <artifactId>jena</artifactId>
     <version>5.3.0-SNAPSHOT</version>
   </parent>
-
+  <profiles>
+   <!-- apache lucene emits warnings for native access and for the vector module for java version >= 21 -->
+   <profile><id>enable-native-and-incubator-vector</id>
+   <activation>
+     <jdk>[21,22,23]</jdk>
+   </activation>
+     <properties>
+       <jena.text.test.argLine>--enable-native-access=ALL-UNNAMED --add-modules jdk.incubator.vector</jena.text.test.argLine>
+     </properties>
+   </profile>
+ </profiles>
   <properties>
+    <jena.text.test.argLine></jena.text.test.argLine>
+    <argLine></argLine>
     <automatic.module.name>org.apache.jena.text</automatic.module.name>
   </properties>
 
@@ -122,6 +134,7 @@
           <includes>
             <include>**/TS_*.java</include>
           </includes>
+          <argLine>@{argLine} ${jena.text.test.argLine}</argLine>
         </configuration>
       </plugin>
 


Test patch:
diff --git a/jena-ontapi/src/test/java/org/apache/jena/ontapi/OntModelMiscTest.java b/jena-ontapi/src/test/java/org/apache/jena/ontapi/OntModelMiscTest.java
index fe11343c04..72cb0acf88 100644
--- a/jena-ontapi/src/test/java/org/apache/jena/ontapi/OntModelMiscTest.java
+++ b/jena-ontapi/src/test/java/org/apache/jena/ontapi/OntModelMiscTest.java
@@ -22,10 +22,14 @@ import org.apache.jena.graph.Graph;
 import org.apache.jena.graph.Triple;
 import org.apache.jena.ontapi.impl.GraphListenerBase;
 import org.apache.jena.ontapi.model.OntClass;
+import org.apache.jena.ontapi.model.OntDisjoint;
 import org.apache.jena.ontapi.model.OntModel;
+import org.apache.jena.ontapi.utils.OntModels;
 import org.apache.jena.rdf.model.Model;
 import org.apache.jena.rdf.model.ModelFactory;
 import org.apache.jena.rdf.model.Resource;
+import org.apache.jena.shared.PrefixMapping;
+import org.apache.jena.vocabulary.OWL;
 import org.apache.jena.vocabulary.OWL2;
 import org.apache.jena.vocabulary.RDF;
 import org.junit.jupiter.api.Assertions;
@@ -99,4 +103,55 @@ public class OntModelMiscTest {
         Assertions.assertTrue(d.contains(d.createResource("http://ex2/B"), RDF.type, OWL2.Class));
     }
 
+    @Test
+    public void testOntDisjointProperties() {
+        var m = ModelFactory.createDefaultModel().setNsPrefixes(PrefixMapping.Standard);
+        var p1 = m.createResource("p1", OWL.DatatypeProperty);
+        var p2 = m.createResource("p2", OWL.DatatypeProperty);
+        var d = m.createResource().addProperty(RDF.type, OWL.AllDisjointProperties);
+        var list = m.createList(p1, p2);
+        d.addProperty(OWL.members, list);
+
+        var ont = OntModelFactory.createModel(m.getGraph());
+        var actual1 = ont.ontObjects(OntDisjoint.DataProperties.class).toList();
+        Assertions.assertEquals(1, actual1.size());
+
+        var actual2 = ont.ontObjects(OntDisjoint.ObjectProperties.class).toList();
+        Assertions.assertEquals(0, actual2.size());
+
+        var actual3 = ont.ontObjects(OntDisjoint.class).toList();
+        Assertions.assertEquals(1, actual3.size());
+        Assertions.assertEquals(OntDisjoint.DataProperties.class, OntModels.getOntType(actual3.get(0)));
+
+        Assertions.assertThrows(IllegalArgumentException.class, ont::createDisjointObjectProperties);
+        Assertions.assertThrows(IllegalArgumentException.class, ont::createDisjointDataProperties);
+    }
+
+    @Test
+    public void testOntDisjointClasses() {
+        var m = ModelFactory.createDefaultModel().setNsPrefixes(PrefixMapping.Standard);
+        var d = m.createResource().addProperty(RDF.type, OWL.AllDisjointClasses);
+        var list = m.createList();
+        d.addProperty(OWL.members, list);
+
+        var ont = OntModelFactory.createModel(m.getGraph());
+        var actual1 = ont.ontObjects(OntDisjoint.Classes.class).toList();
+        Assertions.assertEquals(0, actual1.size());
+
+        Assertions.assertThrows(IllegalArgumentException.class, ont::createDisjointClasses);
+    }
+
+    @Test
+    public void testOntDisjointIndividuals() {
+        var m = ModelFactory.createDefaultModel().setNsPrefixes(PrefixMapping.Standard);
+        var d = m.createResource().addProperty(RDF.type, OWL.AllDifferent);
+        var list = m.createList();
+        d.addProperty(OWL.members, list);
+
+        var ont = OntModelFactory.createModel(m.getGraph());
+        var actual1 = ont.ontObjects(OntDisjoint.Individuals.class).toList();
+        Assertions.assertEquals(0, actual1.size());
+
+        Assertions.assertThrows(IllegalArgumentException.class, ont::createDifferentIndividuals);
+    }
 }
diff --git a/jena-ontapi/src/test/java/org/apache/jena/ontapi/OntModelOWL1SpecsTest.java b/jena-ontapi/src/test/java/org/apache/jena/ontapi/OntModelOWL1SpecsTest.java
index c2ad938e31..eec304b72f 100644
--- a/jena-ontapi/src/test/java/org/apache/jena/ontapi/OntModelOWL1SpecsTest.java
+++ b/jena-ontapi/src/test/java/org/apache/jena/ontapi/OntModelOWL1SpecsTest.java
@@ -189,21 +189,24 @@ public class OntModelOWL1SpecsTest {
         OntModel m = OntModelFactory.createModel(spec.inst);
         OntIndividual i1 = m.getOWLThing().createIndividual("A");
         OntIndividual i2 = m.getOWLThing().createIndividual("B");
+        OntClass c1 = m.createOntClass("C");
+        OntDataProperty p1 = m.createDataProperty("p1");
+        OntObjectProperty p2 = m.createObjectProperty("p2");
         OntDisjoint.Individuals d = m.createDifferentIndividuals(i1, i2);
         Assertions.assertEquals(
                 List.of("A", "B"),
                 d.members().map(Resource::getURI).sorted().collect(Collectors.toList())
         );
 
-        Assertions.assertEquals(8, m.statements().count());
+        Assertions.assertEquals(11, m.statements().count());
         Assertions.assertEquals(1, m.ontObjects(OntDisjoint.Individuals.class).count());
         Assertions.assertEquals(1, m.ontObjects(OntDisjoint.class).count());
 
-        Assertions.assertThrows(OntJenaException.Unsupported.class, m::createDisjointClasses);
-        Assertions.assertThrows(OntJenaException.Unsupported.class, m::createDisjointDataProperties);
-        Assertions.assertThrows(OntJenaException.Unsupported.class, m::createDisjointObjectProperties);
+        Assertions.assertThrows(OntJenaException.Unsupported.class, () -> m.createDisjointClasses(c1));
+        Assertions.assertThrows(OntJenaException.Unsupported.class, () -> m.createDisjointDataProperties(p1));
+        Assertions.assertThrows(OntJenaException.Unsupported.class, () -> m.createDisjointObjectProperties(p2));
 
-        Assertions.assertEquals(8, m.statements().count());
+        Assertions.assertEquals(11, m.statements().count());
         Assertions.assertEquals(1, m.ontObjects(OntDisjoint.Individuals.class).count());
         Assertions.assertEquals(1, m.ontObjects(OntDisjoint.class).count());
     }
@@ -244,6 +247,7 @@ public class OntModelOWL1SpecsTest {
     @ParameterizedTest
     @EnumSource(names = {
             "OWL1_MEM",
+            "OWL1_DL_MEM",
             "OWL1_LITE_MEM",
     })
     public void testDisabledFeaturesOWL1(TestSpec spec) {
@@ -259,7 +263,7 @@ public class OntModelOWL1SpecsTest {
                 );
         d.createDataProperty("dp1").addEquivalentProperty(d.createDataProperty("dp2"));
 
-        OntModel m = OntModelFactory.createModel(d.getGraph(), OntSpecification.OWL1_DL_MEM);
+        OntModel m = OntModelFactory.createModel(d.getGraph(), spec.inst);
         OntClass.Named x = m.getOntClass("X");
         OntClass.Named q = m.createOntClass("Q");
         OntDataProperty dp1 = m.createDataProperty("dp1");
diff --git a/jena-ontapi/src/test/java/org/apache/jena/ontapi/OntModelOWL2ELSpecTest.java b/jena-ontapi/src/test/java/org/apache/jena/ontapi/OntModelOWL2ELSpecTest.java
index d7edeaa0a4..4948dc388b 100644
--- a/jena-ontapi/src/test/java/org/apache/jena/ontapi/OntModelOWL2ELSpecTest.java
+++ b/jena-ontapi/src/test/java/org/apache/jena/ontapi/OntModelOWL2ELSpecTest.java
@@ -316,7 +316,9 @@ public class OntModelOWL2ELSpecTest {
     public void testDifferentIndividuals(TestSpec spec) {
         OntModel data = OntModelFactory.createModel();
         data.createDifferentIndividuals(data.createIndividual("a"));
-        data.createDifferentIndividuals();
+        data.createResource()
+                .addProperty(RDF.type, OWL2.AllDifferent)
+                .addProperty(OWL2.members, data.createList());
         data.createDifferentIndividuals(data.createIndividual("b"), data.createIndividual("c"));
 
         OntModel m = OntModelFactory.createModel(data.getGraph(), spec.inst);
@@ -348,7 +350,9 @@ public class OntModelOWL2ELSpecTest {
     public void testDisjointClasses(TestSpec spec) {
         OntModel data = OntModelFactory.createModel();
         data.createDisjointClasses(data.createOntClass("a"));
-        data.createDisjointClasses();
+        data.createResource()
+                .addProperty(RDF.type, OWL2.AllDisjointClasses)
+                .addProperty(OWL2.members, data.createList());
         data.createDisjointClasses(data.createOntClass("b"), data.createOntClass("c"));
 
         OntModel m = OntModelFactory.createModel(data.getGraph(), spec.inst);
diff --git a/jena-ontapi/src/test/java/org/apache/jena/ontapi/OntModelOWL2QLSpecTest.java b/jena-ontapi/src/test/java/org/apache/jena/ontapi/OntModelOWL2QLSpecTest.java
index 5001096a61..e15b612634 100644
--- a/jena-ontapi/src/test/java/org/apache/jena/ontapi/OntModelOWL2QLSpecTest.java
+++ b/jena-ontapi/src/test/java/org/apache/jena/ontapi/OntModelOWL2QLSpecTest.java
@@ -441,7 +441,9 @@ public class OntModelOWL2QLSpecTest {
     public void testDisjointDataProperties(TestSpec spec) {
         OntModel data = OntModelFactory.createModel();
         data.createDisjointDataProperties(data.createDataProperty("a"));
-        data.createDisjointDataProperties();
+        data.createResource()
+                .addProperty(RDF.type, OWL2.AllDisjointProperties)
+                .addProperty(OWL2.members, data.createList());
         data.createDisjointDataProperties(data.createDataProperty("b"), data.createDataProperty("c"));
 
         OntModel m = OntModelFactory.createModel(data.getGraph(), spec.inst);
diff --git a/jena-ontapi/src/test/java/org/apache/jena/ontapi/OntModelOWL2RLSpecTest.java b/jena-ontapi/src/test/java/org/apache/jena/ontapi/OntModelOWL2RLSpecTest.java
index 04ff59dcdb..1f9a1584df 100644
--- a/jena-ontapi/src/test/java/org/apache/jena/ontapi/OntModelOWL2RLSpecTest.java
+++ b/jena-ontapi/src/test/java/org/apache/jena/ontapi/OntModelOWL2RLSpecTest.java
@@ -644,7 +644,9 @@ public class OntModelOWL2RLSpecTest {
     public void testDisjointObjectProperties(TestSpec spec) {
         OntModel data = OntModelFactory.createModel();
         data.createDisjointObjectProperties(data.createObjectProperty("a"));
-        data.createDisjointObjectProperties();
+        data.createResource()
+                .addProperty(RDF.type, OWL2.AllDisjointProperties)
+                .addProperty(OWL2.members, data.createList());
         data.createDisjointObjectProperties(data.createObjectProperty("b"), data.createObjectProperty("c"));
 
         OntModel m = OntModelFactory.createModel(data.getGraph(), spec.inst);