Annotation Type JsOverlay


  • @Retention(RUNTIME)
    @Target({METHOD,FIELD})
    @Documented
    public @interface JsOverlay
    JsOverlay is used to enhance Java API of the native JsTypes and JsFunctions so richer and more Java friendly abstractions could be provided.
     @JsType(isNative=true)
     class Person {
       @JsOverlay
       private static final Person NO_BODY = new Person();
    
       private String name;
       private String lastName;
    
       @JsOverlay
       public String getFullName() {
         return (name + " " + lastName).trim();
       }
     }

    Note that:

    • JsOverlay methods cannot override any existing methods.
    • JsOverlay methods should be effectively final.
    • JsOverlay methods cannot be called from JavaScript
    These restrictions are in place to avoid polymorphism because underneath the original type is not modified and the overlay fields/methods are simply turned into static dispatches.