<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body>
<p><font face="monospace">The asymmetry between exception
declaration & handling in TaskHandle#get and Callable#call
makes it so changes to the throws declaration of a method passed
to StructuredTaskScope#fork can be inadvertently</font><font
face="monospace"> ignored until they cause a problem at runtime.</font></p>
<p><font face="monospace"><br>
</font></p>
<p><font face="monospace">If you were a downstream consumer of an
interface like<br>
</font></p>
<blockquote>
<p><font face="monospace">interface TemperatureSensor {</font></p>
<p><font face="monospace"> double temperature();<br>
</font></p>
<p><font face="monospace">}</font></p>
</blockquote>
<p><font face="monospace">and TemperatureSensor#temperature()'s
fallibility changed, </font><font face="monospace"><font
face="monospace">existing non-STS usages of the method would
not compile</font>:</font></p>
<blockquote>
<p><font face="monospace">interface TemperatureSensor {</font></p>
<p><font face="monospace"> double temperature() throws
I2CException;<br>
</font></p>
<p><font face="monospace">}</font></p>
<p><font face="monospace">gearboxSensor.temperature(); // compile
error: checked exception not caught</font></p>
</blockquote>
<p><font face="monospace">while existing </font><font
face="monospace">usages of the method in calls to
StructuredTaskScope#fork would compile:</font></p>
<p><font face="monospace"></font></p>
<blockquote>
<p><font face="monospace">try (var scope = new
StructuredTaskScope<>()) {</font></p>
<p><font face="monospace"> var temperatureHandle =
scope.fork(gearboxTemperatureSensor::</font><font
face="monospace">temperature);</font></p>
<p><font face="monospace"> // ...<br>
</font></p>
<p><font face="monospace"> scope.join();</font></p>
<p><font face="monospace"> if (temperatureHandle.get() >
GEARBOX_TEMPERATURE_LIMIT) // newly-added checked exception
I2CException is not handled<br>
</font></p>
<p><font face="monospace"> emergencyStop();<br>
</font></p>
<p><font face="monospace">}</font></p>
</blockquote>
<p><font face="monospace"><br>
</font></p>
<p><font face="monospace">A TaskHandle seems a bit like a nullable
value in this regard: it's not clear from the declaration point
whether a presence check is required before the inner value is
accessed.</font></p>
<p><font face="monospace"><br>
</font></p>
<p><font face="monospace">Regards,</font></p>
<p><font face="monospace">Alec<br>
</font></p>
</body>
</html>