[infinispan-dev] Annotated encoded entries

Radim Vansa rvansa at redhat.com
Thu Jul 27 10:02:15 EDT 2017


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/




-- 
Radim Vansa <rvansa at redhat.com>
JBoss Performance Team



More information about the infinispan-dev mailing list