简体   繁体   English

com.sun.istack.internal.Nullable注释和Guice

[英]com.sun.istack.internal.Nullable Annotation and Guice

When Guice says that it recognizes any @Nullable annotation here ( http://code.google.com/p/google-guice/wiki/UseNullable ) does that mean I can use com.sun.istack.internal.Nullable provided by the Java 7 Runtime successfully? 当Guice说它可以识别此处的任何@Nullable注解( http://code.google.com/p/google-guice/wiki/UseNullable )时,这意味着我可以使用com.sun.istack.internal.Nullable Java 7 Runtime成功?

The fact that the package name is com.sun.istack.internal leads me to believe that I probably shouldn't be using it, but it is pretty convenient to use... 软件包名称为com.sun.istack.internal的事实使我相信我可能不应该使用它,但是使用起来非常方便。

You have to use Nullable from javax.annotation package as the example from the site says. 您必须使用javax.annotation包中的Nullable作为站点上的示例。

If you check comments on the site, there are links to proper jar library. 如果您在网站上查看评论,则有指向正确的jar库的链接。

        <dependency>
            <groupId>com.google.code.findbugs</groupId>
            <artifactId>jsr305</artifactId>
            <version>3.0.2</version>
        </dependency>

In my case I was about to use Nullable annotation from IntelliJ package. 就我而言,我将要使用IntelliJ包中的Nullable注释。 :) :)

If null is permissible by your class, you can annotate the field or parameter with @Nullable. 如果类允许使用null,则可以使用@Nullable注释字段或参数。 Guice recognizes any @Nullable annotation, like edu.umd.cs.findbugs.annotations.Nullable or javax.annotation.Nullable . Guice可以识别任何@Nullable批注,例如edu.umd.cs.findbugs.annotations.Nullablejavax.annotation.Nullable —from the Guice site —来自Guice网站

To confirm chrylis 's hunch above, Guice simply tests the name of the class . 为了确认chrylis的直觉,Guice只需测试类的名称

// from core/src/com/google/inject/internal/Nullability.java
if ("Nullable".equals(type.getSimpleName())) {
  return true;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 @com.sun.istack.internal.NotNull 注释 - @com.sun.istack.internal.NotNull annotation Maven:包com.sun.istack.internal不存在 - Maven: package com.sun.istack.internal does not exist rt.jar com.sun.istack.internal包 - rt.jar com.sun.istack.internal packages 进行“使用Spring构建REST服务”教程时,“ com.sun.istack.internal.SAXException2” - 'com.sun.istack.internal.SAXException2' when doing “Building REST services with Spring” tutorial Guice @Nullable注解 - Guice @Nullable annotation 错误:由以下原因引起:com.sun.istack.internal.SAXException2:在此上下文中找不到类java.util.LinkedHashMap或他的任何超类 - Error: Caused by: com.sun.istack.internal.SAXException2: class java.util.LinkedHashMap not found nor either of his superclass in this context java.lang.NoClassDefFoundError: com/sun/istack/localization/Localizable? - java.lang.NoClassDefFoundError: com/sun/istack/localization/Localizable? java.lang.NoClassDefFoundError:com / sun / istack / tools / DefaultAuthenticator $ Receiver - java.lang.NoClassDefFoundError: com/sun/istack/tools/DefaultAuthenticator$Receiver java.lang.NoClassDefFoundError: com/sun/istack/Pool - java.lang.NoClassDefFoundError: com/sun/istack/Pool java.lang.NoSuchMethodError: com.sun.istack.localization.LocalizableMessageFactory - java.lang.NoSuchMethodError: com.sun.istack.localization.LocalizableMessageFactory
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM