I have a wicket project with lambda expressions. On one page when user clicks on back button my application crashes on:
java.lang.IllegalArgumentException: Invalid lambda deserialization
at x.y.z.MyPage$3.$deserializeLambda$(MyPage.java:1)
In the page class (where I return) I'm using lambda expression for implementation of this interface:
public interface Localizator extends Serializable {
String getLocalizedString(String key);
}
And the lambda:
protected void someMethod() {
localize((String key) -> getString(key));
}
When I change lambda to anonymous class, everything works fine. How should I use lambda in this case?
Env: Java 1.8.0_25, Netbeans 8.0.2, Wicket 6.17.0.
EDIT: This is real (but simplified) method with lambda:
@Override
protected DataLoader createDataLoader() {
return new DataLoader(){
@Override
public List loadData() {
...
}
@Override
public List convertToTableRows(List data) {
return Converter.asRowList(
data,
(Record record) -> {...}, // this lambda is OK
(String key) -> getString(key)); // this lambda is crashing
}
@Override
public List filterTableRow() {
...
}
};
}
Converter class:
public class Converter implements Serializable {
public static ArrayList asRowList(List data, OtherLoader loader, Localizator localizator){...}
DataLoader also extends Serializable.
localize()
method look like? – Shenainterface
extendsSerializable
, no additional cast should be necessary. Ensure that the classes are in sync, e.g. that you didn’t compileMyPage.java
against a version of theinterface
which didn’t extendsSerializable
yet and that you don’t try to deserialize using different versions of theMyPage
class. – Cession