Skip to content

Commit ba91881

Browse files
ctruedenclaude
andcommitted
Address Copilot review feedback
Fix the OpWrappersTest template's stale GenericTyped import, so that regenerating the test does not break it. Move the DatasetTypeExtractor service descriptor from ops-compat, which no longer contains that class, to imagej-compat, which does. And give the ops-flim descriptor the TypeExtractor's actual qualified name. Clarify why the DatasetTypeExtractorTest's reifier finds no extractors: its module does not declare that it uses TypeExtractor. Correct stale and wrong information in several READMEs, and fix typos. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent e197fad commit ba91881

15 files changed

Lines changed: 44 additions & 58 deletions

File tree

‎collections/README.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# SciJava Collections
22

3-
Useful implementions of `java.util.Collection`, e.g. for primitive arrays.
3+
Useful implementations of `java.util.Collection`, e.g. for primitive arrays.
44

5-
Not at full-featured as Trove, but simple.
5+
Not as full-featured as Trove, but simple.

‎discovery-test/README.md‎

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,12 @@
1-
# SciJava Ops Service Loader: A [`ServiceLoader`](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/ServiceLoader.html) extension of SciJava Discovery
2-
This module provides an implementation of `Discoverer` that is powered by the `ServiceLoader` from Java's Module System.
1+
# SciJava Discovery Test: Integration tests for SciJava Discovery
32

4-
## What can `ServiceLoaderDiscoverer` discover?
3+
This module exercises `Discoverer` against Java's [`ServiceLoader`](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/ServiceLoader.html) across real module boundaries. It is not intended to be used as a dependency.
54

6-
`ServiceLoaderDiscoverer` can discover implementations of *any* interface declared to be `use`d in its `module-info.java`. Although we limit the `use`d interfaces to those defined in SciJava Ops SPI (this is, after all, an Ops project), the process is the same for any other interface.
5+
Its `module-info.java` `provides` sample implementations of `org.scijava.ops.spi.Op` and `org.scijava.ops.spi.OpCollection`, and its tests check that a `Discoverer` built with `Discoverer.usingProviders(c -> ServiceLoader.load(c).stream())` finds them.
76

8-
# I wrote an implementation, how can I make it discoverable via `ServiceLoaderDiscoverer`?
9-
10-
Suppose your module `com.example.foo` contains an implementation `com.example.foo.FooOp` of `org.scijava.ops.spi.Op`, and you wise to make `FooOp` discoverable from `ServiceLoaderDiscoverer`. Make sure to:
11-
12-
* Declare SciJava Ops Service Loader as a dependency; if using Maven, it looks like this:
13-
14-
```xml
15-
<dependency>
16-
<groupId>org.scijava</groupId>
17-
<artifactId>scijava-ops-serviceLoader</artifactId>
18-
<version>1.0.0</version>
19-
</dependency>
20-
```
21-
* Make sure that the interface being implemented is `use`d in SciJava Ops Service Loader's `module-info.java`
22-
* Declare in your project's `module-info.java`:
7+
Note that `ServiceLoader` can only discover implementations of interfaces that the calling module declares it `uses`. This module therefore declares:
238

249
```java
25-
provides org.scijava.ops.spi.Op with com.example.foo.FooOp;
26-
```
10+
uses org.scijava.ops.spi.Op;
11+
uses org.scijava.ops.spi.OpCollection;
12+
```

‎discovery/README.md‎

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
# SciJava Discovery: A library for the abstraction of service discovery mechanisms
22

3-
This module provides the `Discoverer` interface, an abstraction for service discovery. `Discoverer`s are designed to return `Discovery` objects, which combine the discovered `Object` with a tag (explained below). `Discoverer`s should implement one (or both) of `Discoverer`'s methods:
3+
This module provides the `Discoverer` interface, an abstraction for service discovery: finding implementations of some type, by some mechanism - `ServiceLoader`, a generated annotation index, a YAML file, or a hand-curated list.
44

5-
## `List<Discovery<? extends Class<T>>> Discoverer.implsOfType(Class<T> c)`
5+
## `<T> List<Discovery<T>> Discoverer.discover(Class<T> c)`
66

7-
This method is designed to return a list of implementations of some `Class<?> c`. In other words, `c` is a superclass extended by/interface implemented by each of the returned `Class`es.
7+
The one method a `Discoverer` must implement. It returns a list of `Discovery` descriptors for implementations of `c`. Descriptors, rather than constructed objects, are returned so that mechanisms able to report what is available without loading classes can do so.
88

9-
## `List<Discovery<AnnotatedElement>> Discoverer.elementsTaggedWith(String tagType)`
9+
## `<T> List<T> Discoverer.instances(Class<T> c)`
1010

11-
This method is designed to return a list of `AnnotatedElements` (`Class`es, `Method`s, or `Field`s) tagged with the given tag type.
11+
A convenience for callers that simply want the objects: it constructs an instance from each `Discovery` returned by `discover(c)`.
1212

13-
## Tags
13+
## Creating `Discoverer`s
1414

15-
** TODO**
15+
Static factory methods on `Discoverer` cover the common cases:
16+
17+
* `Discoverer.usingProviders(...)` wraps a function yielding `ServiceLoader.Provider`s, e.g. `Discoverer.usingProviders(c -> ServiceLoader.load(c).stream())`.
18+
* `Discoverer.using(...)` wraps a function yielding already-constructed objects.
19+
* `Discoverer.all()` returns every `Discoverer` provided via `ServiceLoader`.

ops-compat/src/main/resources/META-INF/services/org.scijava.types.extract.TypeExtractor renamed to imagej-compat/src/main/resources/META-INF/services/org.scijava.types.extract.TypeExtractor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# -- DO NOT EDIT -- This file is autogenerated
22
# Instead, modify and re-run <basedir>/bin/generate-meta-inf.sh from the top-level
3-
org.scijava.legacy.types.DatasetTypeExtractor
3+
org.scijava.imagej.compat.DatasetTypeExtractor

‎imagej-compat/src/test/java/org/scijava/imagej/compat/DatasetTypeExtractorTest.java‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,10 @@ public class DatasetTypeExtractorTest {
5454
@Test
5555
public void testDatasetTypeExtractor() {
5656
// Create a TypeReifier
57-
// NB the use of Discoverer.all(Discoverer.usingProviders(c -> ServiceLoader.load(c).stream())) finds no TypeExtractors
58-
// because the scijava-legacy module does not use the TypeExtractor
59-
// interface. Thus it cannot actually reify anything.
57+
// NB the use of Discoverer.usingProviders(c -> ServiceLoader.load(c).stream())
58+
// finds no TypeExtractors because this module does not declare
59+
// "uses org.scijava.types.extract.TypeExtractor", so ServiceLoader
60+
// refuses the lookup. Thus the reifier cannot actually reify anything.
6061
var reifier = new DefaultTypeReifier(Discoverer.all(Discoverer.usingProviders(c -> ServiceLoader.load(c).stream())));
6162
// Create a Dataset
6263
var img = ArrayImgs.unsignedBytes(10, 10);

‎ops-benchmarks/README.md‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,21 @@ This module contains benchmark code used to assess the performance of the SciJav
44

55
# Executing the Benchmarks
66

7-
The following lines can be used to build and execute the benchmarks from the base `scijava-ops-benchmarks` directory on the command line:
7+
The following lines can be used to build and execute the benchmarks from the base `ops-benchmarks` directory on the command line:
88

99
```bash
1010
# Build the benchmarks module
1111
cd ..
12-
mvn -P benchmarks clean install -pl scijava-ops-benchmarks -am
12+
mvn -P benchmarks clean install -pl ops-benchmarks -am
1313

1414
# Copy dependencies into target folder
15-
cd scijava-ops-benchmarks
15+
cd ops-benchmarks
1616
mvn dependency:copy-dependencies
1717

1818
# Execute the benchmarks
19-
java -cp "target/scijava-ops-benchmarks-1.0.0.jar:target/dependency/*" org.openjdk.jmh.Main
19+
java -cp "target/classes:target/dependency/*" org.openjdk.jmh.Main
2020
```
2121

2222
# Adding a new benchmark
2323

24-
The best way to create a new benchmark is to create a new Java class within `src/main/java/org/scijava/benchmarks`. Within this new class, you can add new methods (annotated with `@Benchmark`) which will be automatically invoked when benchmarks are executed using the commands above.
24+
The best way to create a new benchmark is to create a new Java class within `src/main/java/org/scijava/ops/benchmarks`. Within this new class, you can add new methods (annotated with `@Benchmark`) which will be automatically invoked when benchmarks are executed using the commands above.

‎ops-compat/README.md‎

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,17 @@
1-
# SciJava Legacy: A backwards compatibility bridge with older SciJava code
1+
# SciJava Ops Compat: A backwards compatibility bridge with older SciJava code
22

3-
This library provides a bridge between current SciJava libraries
4-
and previous generations (Java 8 / pre-JPMS) of SciJava/ImageJ2 code.
3+
This library provides a bridge between SciJava Ops
4+
and previous generations (Java 8 / pre-JPMS) of SciJava code.
55

6-
Features include:
7-
8-
* Integration of SciJava Ops into SciJava Common's application context
9-
and module system, via an OpEnvironmentService and preprocessor plugin.
10-
11-
* A SciJava Ops TypeExtractor for ImageJ2's Dataset image type.
6+
It integrates SciJava Ops into SciJava Common's application context
7+
and module system, via an OpEnvironmentService and preprocessor plugin.
128

139
For Maven projects, this library can be used by adding to your `pom.xml`:
1410

15-
```java
11+
```xml
1612
<dependency>
1713
<groupId>org.scijava</groupId>
18-
<artifactId>scijava-legacy</artifactId>
14+
<artifactId>scijava-ops-compat</artifactId>
1915
<version>1.0.0</version>
2016
</dependency>
2117
```

‎ops-engine/src/main/java/org/scijava/ops/engine/util/internal/package-info.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
* This package is designed to house utility methods intended for use <b>only
3232
* within SciJava Ops</b>.
3333
* <p>
34-
* Utilities intended for use outside of this library sould be housed within
34+
* Utilities intended for use outside of this library should be housed within
3535
* the {@code org.scijava.ops.engine.util} package.
3636
*
3737
* @author Gabriel Selzer

‎ops-engine/templates/test/java/org/scijava/ops/engine/matcher/OpWrappersTest.vm‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import org.scijava.function.Producer;
1919
import org.scijava.ops.api.OpBuilder;
2020
import org.scijava.ops.engine.AbstractTestEnvironment;
2121
import org.scijava.ops.engine.OpBuilderTestOps;
22-
import org.scijava.common3.GenericTyped;
22+
import org.scijava.spi.GenericTyped;
2323
import org.scijava.types.Nil;
2424

2525
/**

ops-flim/src/main/resources/META-INF/services/org.scijava.types.TypeExtractor renamed to ops-flim/src/main/resources/META-INF/services/org.scijava.types.extract.TypeExtractor

File renamed without changes.

0 commit comments

Comments
 (0)