Skip to content

Commit

Permalink
build: end support for the Bounds tool and switch to Java 17.
Browse files Browse the repository at this point in the history
Deploying an executable tool into the user's environment is bad
practice.

BREAKING CHANGE : Remove support for the Bounds tool. Subsequently
remove dependency on cami2pnml.

Switch to type-specific stream method on Long collections.

Add explicit dependencies on logback and sfl4j.

Upgrade runtime environment to Java 17.
  • Loading branch information
Lom M. Hillah committed Feb 24, 2022
1 parent 3af891c commit 641eea3
Show file tree
Hide file tree
Showing 12 changed files with 79 additions and 438 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ Download PNML2NUPN executable jar from its [companion web site](http://pnml.lip6
pnml2nupn simply runs on the command line. It is expecting either a set of paths to
PNML files, or to folders containing them, or a mix of files and folders. It scans folders recursively, looking for PNML files.

**Requirement:**
Since version 3.0.0, pnml2nupn runs on Java 11+. Prior versions 2.x.x run on Java 7 to Java 8. Starting from 3.0.0, pnml2nupn will not run on Java below 11.
### Requirement:
- Starting from version 4.0.0, pnml2nupn runs on Java17+.
- In versions 3.x.x, it runs on Java 11+ (starting from 3.0.0, pnml2nupn will not run on Java below 11).
- Prior versions 2.x.x run on Java 7 to Java 8.


### Command-line invocation
Expand Down
2 changes: 1 addition & 1 deletion fr.lip6.move.pnml2nupn/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Bundle-ManifestVersion: 2
Bundle-Name: PNML to Nested Units Petri Nets Translation Tool
Bundle-SymbolicName: fr.lip6.pnml.pnml2nupn;singleton:=true
Bundle-Version: 3.3.0
Bundle-RequiredExecutionEnvironment: JavaSE-11
Bundle-RequiredExecutionEnvironment: JavaSE-17
Export-Package: fr.lip6.move.pnml2nupn;uses:="org.eclipse.jface.resource,org.eclipse.ui.plugin,org.osgi.framework",
fr.lip6.move.pnml2nupn.exceptions,
fr.lip6.move.pnml2nupn.export;uses:="org.slf4j",
Expand Down
33 changes: 22 additions & 11 deletions fr.lip6.move.pnml2nupn/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>fr.lip6.pnml</groupId>
<artifactId>pnml2nupn</artifactId>
<version>3.3.0</version>
<version>4.0.0</version>

<packaging>jar</packaging>

Expand All @@ -22,8 +22,8 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<manifestdir>META-INF</manifestdir>
<sonar.language>java</sonar.language>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
</properties>

<organization>
Expand Down Expand Up @@ -143,11 +143,6 @@
<artifactId>jaxb-impl</artifactId>
<version>3.0.2</version>
</dependency>
<dependency>
<groupId>fr.lip6.pnml</groupId>
<artifactId>fr.lip6.pnml.cami2pnml</artifactId>
<version>2.2.0</version>
</dependency>
<dependency>
<groupId>com.ximpleware</groupId>
<artifactId>vtd-xml</artifactId>
Expand All @@ -158,6 +153,16 @@
<artifactId>fastutil</artifactId>
<version>8.5.6</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.36</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.2.10</version>
</dependency>
</dependencies>

<build>
Expand All @@ -182,9 +187,10 @@
<resource>
<directory>src/main/resources</directory>
<targetPath>main/resources</targetPath>
<includes>
<include>bounds</include>
</includes>
<excludes>
<exclude>bounds</exclude>
<exclude>safety</exclude>
</excludes>
</resource>
<resource>
<directory>src/main/resources</directory>
Expand Down Expand Up @@ -314,6 +320,11 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.cyclonedx</groupId>
<artifactId>cyclonedx-maven-plugin</artifactId>
<version>2.5.3</version>
</plugin>
</plugins>
<pluginManagement>
<plugins>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -417,22 +417,24 @@ public static boolean isForceNUPNGen() {
}

/**
* Returns true if unit safeness checking is enabled (default), false otherwise.
* Returns true if unit safeness checking is enabled, false otherwise.
* Permanently disabled since v4.0.0
*
* @return
*/
public static boolean isUnitSafenessChecking() {
return boolOptionsMap.getBoolean(UNIT_SAFENESS_CHECKING);
return false;
}

/**
* Returns true if unit safeness checking only is enabled, false otherwise
* (default).
* Permanently disabled since v4.0.0
*
* @return
*/
public static boolean isUnitSafenessCheckingOnly() {
return boolOptionsMap.getBoolean(UNIT_SAFENESS_CHECKING_ONLY);
return false;
}

public static boolean isPreserveNupnMix() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@
import com.ximpleware.extended.XPathParseExceptionHuge;

import fr.lip6.move.pnml2nupn.MainPNML2NUPN;
import fr.lip6.move.pnml2nupn.exceptions.PNMLImportExportException;
import fr.lip6.move.pnml2nupn.utils.PNML2NUPNUtils;
import fr.lip6.move.pnml2nupn.utils.SafePNChecker;
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;

/**
Expand Down Expand Up @@ -58,19 +56,6 @@ public static boolean isPTNet(AutoPilotHuge ap, VTDNavHuge vn, Logger logger)
return result;
}

/**
* Checks that the currently analyzed net is 1-safe
*
* @return true if the net is 1-safe
* @throws IOException
* @throws PNMLImportExportException
*/
public static boolean isNet1Safe(SafePNChecker spnc, File inputFile) throws IOException, PNMLImportExportException {
spnc.setPnmlDocPath(inputFile.getCanonicalPath());
boolean res = spnc.isNet1Safe();
return res;
}

/**
* Inserts unit safeness pragma (as reported by the unit safeness checking tool)
* @param nupnQueue the output queue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
import fr.lip6.move.pnml2nupn.exceptions.PNMLImportExportException;
import fr.lip6.move.pnml2nupn.export.PNML2NUPNExporter;
import fr.lip6.move.pnml2nupn.utils.PNML2NUPNUtils;
import fr.lip6.move.pnml2nupn.utils.SafePNChecker;
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
import it.unimi.dsi.fastutil.longs.LongAVLTreeSet;
import it.unimi.dsi.fastutil.longs.LongArrayList;
Expand Down Expand Up @@ -79,7 +78,6 @@ public final class PNML2NUPNExporterImpl implements PNML2NUPNExporter {
private Object2LongOpenHashMap<String> unsafeArcsMap;

private File currentInputFile;
private SafePNChecker spnc;
private long nbUnsafeArcs, nbUnsafePlaces, nbUnsafeTrans;
private long nbTransIn, nbTransOut, nbTransInOut;
// For places and transitions id count
Expand Down Expand Up @@ -109,9 +107,7 @@ public final class PNML2NUPNExporterImpl implements PNML2NUPNExporter {
/* For greatest label length - since v-3.0.0. */
private int labelLength;

public PNML2NUPNExporterImpl() {
spnc = new SafePNChecker();
}
public PNML2NUPNExporterImpl() {}

@Override
public void export2NUPN(URI inFile, URI outFile, Logger journal)
Expand Down Expand Up @@ -301,47 +297,9 @@ private void translateIntoNUPN(File inFile, File outFile, Logger journal) throws
"The net in the document is not a P/T Net. Only P/T Nets are supported: "
+ this.currentInputFile.getCanonicalPath());
}
// The net must be 1-safe, if bounds checking is enabled.
if (MainPNML2NUPN.isUnitSafenessChecking()) {
logger.info("Checking if this net is 1-Safe.");
if (!(isSafe = ExportUtils.isNet1Safe(spnc, this.currentInputFile))) {
if (SafePNChecker.isBoundsVerdictInconclusive()) {
journal.warn(
"This net cannot be proven 1-safe or unsafe (the Bounds tool could not compute the bounds using structural analysis of place bounds): "
+ this.currentInputFile.getCanonicalPath());
} else {
journal.error(
"This net is not 1-safe (proven by the Bounds tool using structural analysis of place bounds): "
+ this.currentInputFile.getCanonicalPath());
journal.error("\nUNSAFE PLACES: {}", generateUnsafePlacesReport());
}

if (MainPNML2NUPN.isForceNUPNGen() && !MainPNML2NUPN.isUnitSafenessCheckingOnly()) {
journal.warn("Forced NUPN generation is set => Continuing NUPN generation.");
} else {
if (!MainPNML2NUPN.isUnitSafenessCheckingOnly()) {
if (SafePNChecker.isBoundsVerdictInconclusive()) {
journal.warn(
"Potentially unsafe net (inconclusive verdict by the Bounds tool) => Continuing NUPN generation.");
} else {
throw new InvalidSafeNetException(
"Unsafe net in " + this.currentInputFile.getCanonicalPath());
}
}
}
} else {
logger.info(
"This net is 1-safe (proven by the Bounds tool using structural analysis of place bounds): {}",
this.currentInputFile.getCanonicalPath());
}
if (MainPNML2NUPN.isUnitSafenessCheckingOnly()) {
journal.info("Unit safeness checking only requested. Will stop here.");
throw new EarlyStopException(
"Unit safeness checking only requested on " + this.currentInputFile.getCanonicalPath());
}
} else {
logger.warn("Unit safeness checking is disabled. I don't know if this net is 1-Safe.");
}
// The net must be 1-safe, but bounds checking is no longer supported from v4.0.0
logger.warn("Unit safeness checking is permanently disabled. I don't know if this net is 1-Safe.");

// Open NUPN and mapping files channels, and init write queues
outTSFile = new File(PNML2NUPNUtils.extractBaseName(outFile.getCanonicalPath()) + NUPNConstants.TRANS_EXT);
outPSFile = new File(PNML2NUPNUtils.extractBaseName(outFile.getCanonicalPath()) + NUPNConstants.STATES_EXT);
Expand Down Expand Up @@ -408,9 +366,6 @@ private void translateIntoNUPN(File inFile, File outFile, Logger journal) throws
// clear maps
clearAllCollections();
logger.info("See NUPN file: {}", outFile.getCanonicalPath());
} catch (EarlyStopException e) {
normalStop(outFile);
throw e;
} catch (NavExceptionHuge | XPathParseExceptionHuge | XPathEvalExceptionHuge | InvalidSafeNetException
| InternalException | InvalidNetException e) {
emergencyStop(outFile);
Expand Down Expand Up @@ -688,11 +643,11 @@ private void buildUnsafeArcsPragma(BlockingQueue<String> nupnQueue) throws Inter
// they could also have incoming arcs with valuation = 1...
arcVals = tr2InAllArcsMap.get(s);
if (arcVals != null) {
long arcValsSafe = arcVals.stream().filter(v -> v == 1L).map(x -> x).reduce(0L, (a, b) -> a + b);
long arcValsSafe = arcVals.longStream().filter(v -> v == 1L).map(x -> x).reduce(0L, (a, b) -> a + b);
if (arcValsSafe > 0L) {
inValT += arcValsSafe;
warnMsg.append(", safe incoming arc(s) with respective valuation(s):");
arcVals.stream().filter(v -> v == 1).forEach(v -> {
arcVals.longStream().filter(v -> v == 1).forEach(v -> {
warnMsg.append(NUPNConstants.WS).append(v);
});
}
Expand Down Expand Up @@ -723,11 +678,11 @@ private void buildUnsafeArcsPragma(BlockingQueue<String> nupnQueue) throws Inter
// they could also have outgoing arcs with valuation = 1...
arcVals = tr2OutAllArcsMap.get(s);
if (arcVals != null) {
long arcValsSafe = arcVals.stream().filter(v -> v == 1L).map(x -> x).reduce(0L, (a, b) -> a + b);
long arcValsSafe = arcVals.longStream().filter(v -> v == 1L).map(x -> x).reduce(0L, (a, b) -> a + b);
if (arcValsSafe > 0L) {
outValT += arcValsSafe;
warnMsg.append(", and safe outgoing arc(s) with respective valuation(s):");
arcVals.stream().filter(v -> v == 1).forEach(v -> {
arcVals.longStream().filter(v -> v == 1).forEach(v -> {
warnMsg.append(NUPNConstants.WS).append(v);
});
}
Expand Down Expand Up @@ -770,11 +725,11 @@ private void buildUnsafeArcsPragma(BlockingQueue<String> nupnQueue) throws Inter
// they could also have outgoing arcs with valuation = 1...
arcVals = tr2OutAllArcsMap.get(s);
if (arcVals != null) {
long arcValsSafe = arcVals.stream().filter(v -> v == 1).map(x -> x).reduce(0L, (a, b) -> a + b);
long arcValsSafe = arcVals.longStream().filter(v -> v == 1).map(x -> x).reduce(0L, (a, b) -> a + b);
if (arcValsSafe > 0L) {
outValT += arcValsSafe;
warnMsg.append(", safe outgoing arc(s) with respective valuation(s):");
arcVals.stream().filter(v -> v == 1).forEach(v -> {
arcVals.longStream().filter(v -> v == 1).forEach(v -> {
warnMsg.append(NUPNConstants.WS).append(v);
});
}
Expand All @@ -785,10 +740,10 @@ private void buildUnsafeArcsPragma(BlockingQueue<String> nupnQueue) throws Inter
if (arcVals != null) {
warnMsg.append(", and ").append(arcVals.size64())
.append(" safe incoming arc(s) with respective valuation(s):");
long arcValsSafe = arcVals.stream().filter(v -> v == 1).map(x -> x).reduce(0L, (a, b) -> a + b);
long arcValsSafe = arcVals.longStream().filter(v -> v == 1).map(x -> x).reduce(0L, (a, b) -> a + b);
if (arcValsSafe > 0L) {
inValT += arcValsSafe;
arcVals.stream().filter(v -> v == 1).forEach(v -> {
arcVals.longStream().filter(v -> v == 1).forEach(v -> {
warnMsg.append(NUPNConstants.WS).append(v);
});
}
Expand Down Expand Up @@ -1160,7 +1115,7 @@ private void exportPlacesIntoUnits(AutoPilotHuge ap, VTDNavHuge vn, BlockingQueu
"List of consecutive places IDs not being in arithmetic progression in unit {} ({}): {}",
unitSId, unitLId, faultyIds.toString());
logger.error("Consequently, the NUPN output for units will not be syntax-compliant.");
placesIntId.stream().forEach(i -> nupnsb.append(NUPNConstants.WS).append(i));
placesIntId.longStream().forEach(i -> nupnsb.append(NUPNConstants.WS).append(i));
faultyIds.clear();
} else {
nupnsb.append(NUPNConstants.WS).append(placesIntId.getLong(0)).append(NUPNConstants.DOTS)
Expand Down Expand Up @@ -1246,8 +1201,8 @@ private void exportPlacesIntoUnits(AutoPilotHuge ap, VTDNavHuge vn, BlockingQueu
}

// Then the rest
List<Long> otherPlaces = placesId2NupnMap.values().stream().filter(v -> !initPlaces.contains(v)).sorted()
.collect(Collectors.toList());
List<Long> otherPlaces = placesId2NupnMap.values().longStream().filter(v -> !initPlaces.contains(v)).sorted()
.collect(ArrayList::new, ArrayList::add, ArrayList::addAll);
for (Long nupnId : otherPlaces) {
nupnsb.append(NUPNConstants.U).append(count).append(NUPNConstants.WS).append(NUPNConstants.HK)
.append(NUPNConstants.ONE).append(NUPNConstants.WS).append(nupnId).append(NUPNConstants.DOTS)
Expand Down Expand Up @@ -1311,10 +1266,6 @@ private void exportPlacesIntoUnits(AutoPilotHuge ap, VTDNavHuge vn, BlockingQueu
}
}

private String generateUnsafePlacesReport() {
return spnc.getExplanation();
}

/**
* Inits the log.
*
Expand Down Expand Up @@ -1410,17 +1361,6 @@ private void emergencyStop(File outFile) throws InterruptedException, IOExceptio
logger.error("Emergency stop. Cancelled the translation and released opened resources.");
}

/**
* Normal stop.
*
* @param outFile
* @throws InterruptedException
* @throws IOException
*/
private void normalStop(File outFile) throws InterruptedException, IOException {
stop(outFile);
}

/**
* Stops NUPN writers and releases resources
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ public static final long arithmeticProgression(LongList ll) {
}

public static final long sum(LongList ll) {
return ll.stream().mapToLong(x -> x).sum();
return ll.longStream().sum();
}

/**
Expand Down
Loading

0 comments on commit 641eea3

Please sign in to comment.