Guava r07, GWT and javax.annotation.Nullable

前端 未结 3 1172
遥遥无期
遥遥无期 2020-12-14 17:22

I\'m trying to use Guava in a GWT project without success (a HashMultimap, to be precise). I get a never-ending list of stacktraces for classes:

  • com.google.co
3条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-14 17:32

    You need to obtain the JSR 305 JAR, but in addition, you need to include the @Nullable annotation source code as food for the GWT compiler.

    Assuming your project is under com/example/myproject/ Create a file: com/example/myproject/annotation/javax/annotation/Nullable.java With the following content:

    package com.example.myproject.annotation.javax.annotation;
    
    import java.lang.annotation.Documented;
    import java.lang.annotation.Retention;
    import java.lang.annotation.RetentionPolicy;
    
    import javax.annotation.Nonnull;
    import javax.annotation.meta.TypeQualifierNickname;
    import javax.annotation.meta.When;
    
    @Documented
    @TypeQualifierNickname
    @Nonnull(when = When.UNKNOWN)
    @Retention(RetentionPolicy.RUNTIME)
    public @interface Nullable {
    
    }
    

    Add the line to MyProject.gwt.xml:

    
    

    And you're good to go.

提交回复
热议问题