Reputation: 645
Most of our code packages have a package-info.java that specifies @NonNullByDefault. (This has drastically reduced the number of NullPointerExceptions we encounter)
I now need to write a TransferHandler for a class - but it seems impossible to do if @NonNullByDefault is in effect. This code shows the issue:
private static class ProductTransferHandler extends TransferHandler {
private static final long serialVersionUID = 1L;
@Override
public boolean canImport(final @Nullable TransferHandler.TransferSupport info) {
return false;
}
@Override
public boolean importData(final TransferHandler.TransferSupport info) {
if (!info.isDrop()) {
return false;
}
return false;
}
}
Both of the methods are marked as an error in eclipse:
Illegal redefinition of parameter info, inherited method from TransferHandler does not constrain this parameter
It doesn't matter if the @Nullable is there or not. Same error either way.
Is there ANY way to do this with @NonNullByDefault in effect? Or do I have to move this class to it's own file in some other package just to NOT do that?
Upvotes: 0
Views: 15