Skip to content

Commit

Permalink
Merge pull request #3815 from sbesson/java_17
Browse files Browse the repository at this point in the history
Java 17 support
  • Loading branch information
dgault authored Jan 31, 2023
2 parents ef03cc9 + f6d9c4b commit f0017bd
Show file tree
Hide file tree
Showing 9 changed files with 91 additions and 56 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ant.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
build:
strategy:
matrix:
java: [1.8, 11]
java: [1.8, 11, 17]
os: [ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
build:
strategy:
matrix:
java: [1.8, 11]
java: [1.8, 11, 17]
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
env:
Expand Down
2 changes: 1 addition & 1 deletion components/formats-bsd/src/loci/formats/in/JPEGReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ public void close(boolean fileOnly) throws IOException {

// -- Helper reader --

static class DefaultJPEGReader extends ImageIOReader {
public static class DefaultJPEGReader extends ImageIOReader {
public DefaultJPEGReader() {
super("JPEG", new String[] {"jpg", "jpeg", "jpe"});
suffixNecessary = false;
Expand Down
3 changes: 1 addition & 2 deletions components/formats-gpl/src/loci/formats/in/CV7000Reader.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ public class CV7000Reader extends FormatReader {
// -- Fields --

private String[] allFiles;
private Location parent;
private MinimalTiffReader reader;
private String wppPath;
private String detailPath;
Expand Down Expand Up @@ -239,7 +238,7 @@ protected void initFile(String id) throws FormatException, IOException {
String wpiXML = readSanitizedXML(id);
XMLTools.parseXML(wpiXML, plate);

parent = new Location(id).getAbsoluteFile().getParentFile();
Location parent = new Location(id).getAbsoluteFile().getParentFile();
allFiles = parent.list(true);
Arrays.sort(allFiles);
for (int i=0; i<allFiles.length; i++) {
Expand Down
48 changes: 21 additions & 27 deletions components/formats-gpl/src/loci/formats/in/CellVoyagerReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,18 +111,17 @@ public class CellVoyagerReader extends FormatReader

private static final String SINGLE_TIFF_PATH_BUILDER = "W%dF%03dT%04dZ%02dC%d.tif";

private Location measurementFolder;
private Location imageFolder;
private String imageFolder;

private List< ChannelInfo > channelInfos;

private List< WellInfo > wells;

private List< Integer > timePoints;

private Location measurementResultFile;
private String measurementResultFile;

private Location omeMeasurementFile;
private String omeMeasurementFile;

public CellVoyagerReader()
{
Expand All @@ -148,8 +147,6 @@ public byte[] openBytes( final int no, final byte[] buf, final int x, final int
final AreaInfo area = well.areas.get( areaIndex );
final MinimalTiffReader tiffReader = new MinimalTiffReader();

imageFolder = new Location(currentId).getAbsoluteFile().getParentFile();
imageFolder = new Location(imageFolder, "Image");
for ( final FieldInfo field : area.fields )
{

Expand Down Expand Up @@ -274,7 +271,7 @@ protected void initFile( final String id ) throws FormatException, IOException
{
super.initFile( id );

measurementFolder = new Location( id ).getAbsoluteFile();
Location measurementFolder = new Location( id ).getAbsoluteFile();
if ( !measurementFolder.exists() ) { throw new IOException( "File " + id + " does not exist." ); }
if ( !measurementFolder.isDirectory() )
{
Expand All @@ -283,22 +280,26 @@ protected void initFile( final String id ) throws FormatException, IOException
measurementFolder = measurementFolder.getParentFile();
}
}
imageFolder = new Location(measurementFolder, "Image");
imageFolder = new Location(measurementFolder, "Image").getAbsolutePath();

measurementResultFile = new Location( measurementFolder, "MeasurementResult.xml" );
if ( !measurementResultFile.exists() ) { throw new IOException( "Could not find " + measurementResultFile + " in folder." ); }
Location measurementResult = new Location( measurementFolder, "MeasurementResult.xml" );
if ( !measurementResult.exists() ) { throw new IOException( "Could not find " + measurementResult + " in folder." ); }
else {
measurementResultFile = measurementResult.getAbsolutePath();
}

omeMeasurementFile = new Location( measurementFolder, "MeasurementResult.ome.xml" );
if ( !omeMeasurementFile.exists() ) { throw new IOException( "Could not find " + omeMeasurementFile + " in folder." ); }
Location omeMeasurement = new Location( measurementFolder, "MeasurementResult.ome.xml" );
if ( !omeMeasurement.exists() ) { throw new IOException( "Could not find " + omeMeasurement + " in folder." ); }
else {
omeMeasurementFile = omeMeasurement.getAbsolutePath();
}

/*
* Open MeasurementSettings file
*/

RandomAccessInputStream result =
new RandomAccessInputStream(measurementResultFile.getAbsolutePath());
Document msDocument = null;
try {
try (RandomAccessInputStream result = new RandomAccessInputStream(measurementResultFile)) {
msDocument = XMLTools.parseDOM(result);
}
catch (ParserConfigurationException e) {
Expand All @@ -307,9 +308,6 @@ protected void initFile( final String id ) throws FormatException, IOException
catch (SAXException e) {
throw new IOException(e);
}
finally {
result.close();
}

msDocument.getDocumentElement().normalize();

Expand All @@ -329,10 +327,9 @@ protected void initFile( final String id ) throws FormatException, IOException
* Open OME metadata file
*/

RandomAccessInputStream measurement =
new RandomAccessInputStream(omeMeasurementFile.getAbsolutePath());

Document omeDocument = null;
try {
try (RandomAccessInputStream measurement = new RandomAccessInputStream(omeMeasurementFile)) {
omeDocument = XMLTools.parseDOM(measurement);
}
catch (ParserConfigurationException e) {
Expand All @@ -341,9 +338,6 @@ protected void initFile( final String id ) throws FormatException, IOException
catch (SAXException e) {
throw new IOException(e);
}
finally {
measurement.close();
}
omeDocument.getDocumentElement().normalize();

/*
Expand All @@ -361,7 +355,7 @@ public String[] getSeriesUsedFiles( final boolean noPixels )

if ( noPixels )
{
return new String[] { measurementResultFile.getAbsolutePath(), omeMeasurementFile.getAbsolutePath() };
return new String[] { measurementResultFile, omeMeasurementFile };
}
else
{
Expand All @@ -371,8 +365,8 @@ public String[] getSeriesUsedFiles( final boolean noPixels )
final AreaInfo area = wells.get( wellIndex ).areas.get( areaIndex );
final int nFields = area.fields.size();
ArrayList<String> images = new ArrayList<String>();
images.add(measurementResultFile.getAbsolutePath());
images.add(omeMeasurementFile.getAbsolutePath());
images.add(measurementResultFile);
images.add(omeMeasurementFile);

for ( final Integer timepoint : timePoints )
{
Expand Down
55 changes: 39 additions & 16 deletions components/formats-gpl/src/loci/formats/in/PrairieReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public class PrairieReader extends FormatReader {
private TiffReader tiff;

/** The associated XML files. */
private Location xmlFile, cfgFile, envFile;
private String xmlFile, cfgFile, envFile;

/** Format-specific metadata. */
private PrairieMetadata meta;
Expand Down Expand Up @@ -215,9 +215,9 @@ public String[] getSeriesUsedFiles(boolean noPixels) {

// add metadata files to the used files list
final ArrayList<String> usedFiles = new ArrayList<String>();
if (xmlFile != null) usedFiles.add(xmlFile.getAbsolutePath());
if (cfgFile != null) usedFiles.add(cfgFile.getAbsolutePath());
if (envFile != null) usedFiles.add(envFile.getAbsolutePath());
if (xmlFile != null) usedFiles.add(xmlFile);
if (cfgFile != null) usedFiles.add(cfgFile);
if (envFile != null) usedFiles.add(envFile);

if (!noPixels) {
// add TIFF files to the used files list
Expand Down Expand Up @@ -319,15 +319,15 @@ protected void initFile(String id) throws FormatException, IOException {
tiff = new TiffReader();

if (checkSuffix(id, XML_SUFFIX)) {
xmlFile = new Location(id);
xmlFile = new Location(id).getAbsolutePath();
findMetadataFiles();
}
else if (checkSuffix(id, CFG_SUFFIX)) {
cfgFile = new Location(id);
cfgFile = new Location(id).getAbsolutePath();
findMetadataFiles();
}
else if (checkSuffix(id, ENV_SUFFIX)) {
envFile = new Location(id);
envFile = new Location(id).getAbsolutePath();
findMetadataFiles();
}
else {
Expand All @@ -344,7 +344,7 @@ else if (checkSuffix(id, ENV_SUFFIX)) {
}
}

currentId = xmlFile.getAbsolutePath();
currentId = xmlFile;

parsePrairieMetadata();
populateCoreMetadata();
Expand All @@ -356,9 +356,24 @@ else if (checkSuffix(id, ENV_SUFFIX)) {

private void findMetadataFiles() {
LOGGER.info("Finding metadata files");
if (xmlFile == null) xmlFile = find(XML_SUFFIX);
if (cfgFile == null) cfgFile = find(CFG_SUFFIX);
if (envFile == null) envFile = find(ENV_SUFFIX);
if (xmlFile == null) {
Location xml = find(XML_SUFFIX);
if (xml != null) {
xmlFile = xml.getAbsolutePath();
}
}
if (cfgFile == null) {
Location cfg = find(CFG_SUFFIX);
if (cfg != null) {
cfgFile = cfg.getAbsolutePath();
}
}
if (envFile == null) {
Location env = find(ENV_SUFFIX);
if (env != null) {
envFile = env.getAbsolutePath();
}
}
}

/**
Expand All @@ -368,11 +383,19 @@ private void findMetadataFiles() {
private void parsePrairieMetadata() throws FormatException, IOException {
LOGGER.info("Parsing Prairie metadata");

final Document xml, cfg, env;
Document xml = null;
Document cfg = null;
Document env = null;
try {
xml = parseDOM(xmlFile);
cfg = parseDOM(cfgFile);
env = parseDOM(envFile);
if (xmlFile != null) {
xml = parseDOM(new Location(xmlFile));
}
if (cfgFile != null) {
cfg = parseDOM(new Location(cfgFile));
}
if (envFile != null) {
env = parseDOM(new Location(envFile));
}
}
catch (ParserConfigurationException exc) {
throw new FormatException(exc);
Expand Down Expand Up @@ -725,7 +748,7 @@ private void warnFilename(final Sequence sequence, final int index,

/** Gets the absolute path to the filename of the given {@link PFile}. */
private String getPath(final PFile file) {
final Location f = new Location(xmlFile.getParent(), file.getFilename());
final Location f = new Location(new Location(xmlFile).getParent(), file.getFilename());
return f.getAbsolutePath();
}

Expand Down
13 changes: 7 additions & 6 deletions components/formats-gpl/src/loci/formats/in/VolocityReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public class VolocityReader extends FormatReader {
private ArrayList<Stack> stacks;
private ArrayList<String> extraFiles;
private Object[][] sampleTable, stringTable;
private Location dir = null;
private String dir = null;

private ArrayList<Double[]> timestamps = new ArrayList<Double[]>();

Expand Down Expand Up @@ -258,13 +258,14 @@ protected void initFile(String id) throws FormatException, IOException {
extraFiles.add(file.getAbsolutePath());

Location parentDir = file.getParentFile();
dir = new Location(parentDir, DATA_DIR);
Location dataDir = new Location(parentDir, DATA_DIR);
dir = dataDir.getAbsolutePath();

if (dir.exists()) {
String[] files = dir.list(true);
if (dataDir.exists()) {
String[] files = dataDir.list(true);
for (String f : files) {
if (!checkSuffix(f, "aisf") && !checkSuffix(f, "atsf")) {
extraFiles.add(new Location(dir, f).getAbsolutePath());
extraFiles.add(new Location(dataDir, f).getAbsolutePath());
}
}
}
Expand Down Expand Up @@ -851,7 +852,7 @@ private RandomAccessInputStream getStream(int row) throws IOException {
return data;
}

private String getFile(Integer parent, Location dir) {
private String getFile(Integer parent, String dir) {
for (int row=0; row<sampleTable.length; row++) {
if (parent.equals(sampleTable[row][0])) {
Object o = sampleTable[row][14];
Expand Down
20 changes: 19 additions & 1 deletion components/test-suite/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
<dependency>
<groupId>org.kohsuke</groupId>
<artifactId>file-leak-detector</artifactId>
<version>1.13</version>
<version>1.15</version>
<!-- the regular jar does not specify a main class -->
<classifier>jar-with-dependencies</classifier>
<exclusions>
Expand Down Expand Up @@ -165,4 +165,22 @@
<timezone>-6</timezone>
</developer>
</developers>

<repositories>
<repository>
<id>central</id>
<name>Central Repository</name>
<url>https://repo.maven.apache.org/maven2</url>
</repository>
<repository>
<id>ome</id>
<name>OME Artifactory</name>
<url>https://artifacts.openmicroscopy.org/artifactory/maven/</url>
</repository>
<repository>
<id>imagej.public</id>
<name>Jenkins repository</name>
<url>https://repo.jenkins-ci.org/releases/</url>
</repository>
</repositories>
</project>
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
<ome-poi.version>5.3.7</ome-poi.version>
<ome-mdbtools.version>5.3.2</ome-mdbtools.version>
<ome-jai.version>0.1.3</ome-jai.version>
<ome-codecs.version>0.4.1</ome-codecs.version>
<ome-codecs.version>0.4.2</ome-codecs.version>
<jxrlib.version>0.2.4</jxrlib.version>
<xalan.version>2.7.2</xalan.version>
<sqlite.version>3.28.0</sqlite.version>
Expand Down

0 comments on commit f0017bd

Please sign in to comment.