[infinispan-dev] Annotated encoded entries

Adrian Nistor anistor at redhat.com
Thu Jul 27 17:08:38 EDT 2017


That's clever, but a bit too much bloat I'm afraid.

On 07/27/2017 05:02 PM, Radim Vansa wrote:
> Hi guys,
>
> recently the new encoding stuff has dawned in the codebase, and I must
> admit that keeping track what's in storage-format and what's not (and I
> think I've spotted some bugs). I think that we could use Java 8's type
> annotations that would explicitly mark the contents as encoded or not
> encoded:
>
> @Target({ ElementType.FIELD, ElementType.LOCAL_VARIABLE,
> ElementType.PARAMETER, ElementType.TYPE_PARAMETER, ElementType.TYPE_USE })
> public @interface Storage {
> }
>
> @Target({ ElementType.FIELD, ElementType.LOCAL_VARIABLE,
> ElementType.PARAMETER, ElementType.TYPE_PARAMETER, ElementType.TYPE_USE })
> public @interface External {
> }
>
> Then the Encoder would look like:
>
> public interface Encoder {
>      @Storage Object toStorage(@External Object content);
>      @External Object fromStorage(@Storage Object content);
>
> }
>
> Eventually we could use tools like the Checker Framework [1] to enforce
> explicit casts from non-annotated type to annotated. I am still not
> fully decided if we should have separate annotations for keys & values.
>
> While this gives some clarity on use, those annotations would have to be
> rather ubiquitous (code bloat?). Nevertheless, what do you think about it?
>
> Radim
>
> [1] https://checkerframework.org/jsr308/
>
>
>
>



More information about the infinispan-dev mailing list