add throws clauses to Java APIs
This commit is contained in:
parent
bf49b75d5e
commit
e3ac633649
3 changed files with 5 additions and 3 deletions
|
|
@ -93,6 +93,7 @@ object JavaPartialFunction {
|
||||||
abstract class JavaPartialFunction[A, B] extends AbstractPartialFunction[A, B] {
|
abstract class JavaPartialFunction[A, B] extends AbstractPartialFunction[A, B] {
|
||||||
import JavaPartialFunction._
|
import JavaPartialFunction._
|
||||||
|
|
||||||
|
@throws(classOf[Exception])
|
||||||
def apply(x: A, isCheck: Boolean): B
|
def apply(x: A, isCheck: Boolean): B
|
||||||
|
|
||||||
final def isDefinedAt(x: A): Boolean = try { apply(x, true); true } catch { case NoMatch ⇒ false }
|
final def isDefinedAt(x: A): Boolean = try { apply(x, true); true } catch { case NoMatch ⇒ false }
|
||||||
|
|
|
||||||
|
|
@ -217,7 +217,7 @@ public class JavaTestKit {
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract class ReceiveWhile<T> {
|
public abstract class ReceiveWhile<T> {
|
||||||
abstract protected T match(Object msg);
|
abstract protected T match(Object msg) throws Exception;
|
||||||
|
|
||||||
private Object results;
|
private Object results;
|
||||||
|
|
||||||
|
|
@ -237,8 +237,8 @@ public class JavaTestKit {
|
||||||
public ReceiveWhile(Class<T> clazz, Duration max, Duration idle, int messages) {
|
public ReceiveWhile(Class<T> clazz, Duration max, Duration idle, int messages) {
|
||||||
results = p.receiveWhile(max, idle, messages,
|
results = p.receiveWhile(max, idle, messages,
|
||||||
new CachingPartialFunction<Object, T>() {
|
new CachingPartialFunction<Object, T>() {
|
||||||
public T match(Object msg) {
|
public T match(Object msg) throws Exception {
|
||||||
return ReceiveWhile.this.match(msg);
|
return ReceiveWhile.this.match(msg);
|
||||||
}
|
}
|
||||||
}).toArray(Util.classTag(clazz));
|
}).toArray(Util.classTag(clazz));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -732,6 +732,7 @@ trait DefaultTimeout { this: TestKit ⇒
|
||||||
private[testkit] abstract class CachingPartialFunction[A, B <: AnyRef] extends scala.runtime.AbstractPartialFunction[A, B] {
|
private[testkit] abstract class CachingPartialFunction[A, B <: AnyRef] extends scala.runtime.AbstractPartialFunction[A, B] {
|
||||||
import akka.japi.JavaPartialFunction._
|
import akka.japi.JavaPartialFunction._
|
||||||
|
|
||||||
|
@throws(classOf[Exception])
|
||||||
def `match`(x: A): B
|
def `match`(x: A): B
|
||||||
|
|
||||||
var cache: B = _
|
var cache: B = _
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue