MDA/MDD/TDD/DDD/DDDDDDD
          posts - 536, comments - 111, trackbacks - 0, articles - 0
            BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理

          JDK5筆記

          Posted on 2011-10-07 15:05 leekiang 閱讀(509) 評論(0)  編輯  收藏 所屬分類: java
          1,SuppressWarnings的作用是抑制編譯器產生警告信息。
          @SuppressWarnings("unused")
          @SuppressWarnings("unchecked")

          eclipse支持的SuppressWarning的值如下,其他開發工具略有差異。
          • all to suppress all warnings
          • boxing to suppress warnings relative to boxing/unboxing operations
          • cast to suppress warnings relative to cast operations
          • dep-ann to suppress warnings relative to deprecated annotation
          • deprecation to suppress warnings relative to deprecation
          • fallthrough to suppress warnings relative to missing breaks in switch statements
          • finally to suppress warnings relative to finally block that don't return
          • hiding to suppress warnings relative to locals that hide variable
          • incomplete-switch to suppress warnings relative to missing entries in a switch statement (enum case)
          • nls to suppress warnings relative to non-nls string literals
          • null to suppress warnings relative to null analysis
          • restriction to suppress warnings relative to usage of discouraged or forbidden references
          • serial to suppress warnings relative to missing serialVersionUID field for a serializable class
          • static-access to suppress warnings relative to incorrect static access
          • synthetic-access to suppress warnings relative to unoptimized access from inner classes
          • unchecked to suppress warnings relative to unchecked operations
          • unqualified-field-access to suppress warnings relative to field access unqualified
          • unused to suppress warnings relative to unused code
          2,注解
          注解是加入到java源代碼中的一些描述性的數據,本身不能執行。可利用反射(當RetentionPolicy=RUNTIME)或文本解析取得注解信息。
          @Target,@Retention為元注解。
          SuppressWarnings的源碼如下:
          @Target({TYPE,?FIELD,?METHOD,?PARAMETER,?CONSTRUCTOR,?LOCAL_VARIABLE})
          @Retention(RetentionPolicy.SOURCE)
          public?@interface?SuppressWarnings?{
          ????String[]?value();
          }

          package?java.lang.annotation;

          public?enum?RetentionPolicy?{
          ????
          /**
          ?????*?Annotations?are?to?be?discarded?by?the?compiler.
          ?????
          */
          ????SOURCE,

          ????
          /**
          ?????*?Annotations?are?to?be?recorded?in?the?class?file?by?the?compiler
          ?????*?but?need?not?be?retained?by?the?VM?at?run?time.??This?is?the?default
          ?????*?behavior.
          ?????
          */
          ????CLASS,

          ????
          /**
          ?????*?Annotations?are?to?be?recorded?in?the?class?file?by?the?compiler?and
          ?????*?retained?by?the?VM?at?run?time,?so?they?may?be?read?reflectively.
          ?????*
          ?????*?
          @see?java.lang.reflect.AnnotatedElement
          ?????
          */
          ????RUNTIME
          }


          package?java.lang.annotation;
          public?enum?ElementType?{
          ????TYPE,
          ????FIELD,
          ????METHOD,
          ????PARAMETER,
          ????CONSTRUCTOR,
          ????LOCAL_VARIABLE,
          ????ANNOTATION_TYPE,
          ????PACKAGE
          }

          3,泛型

          ????public?<T>?T?testT(List<T>??list){
          ????????T?t?
          =(T)?list;
          ????????
          return?t;
          ????}

          4,自動裝箱(AutoBoxing

          關于row type
          http://stackoverflow.com/questions/2770321/what-is-a-raw-type-and-why-shouldnt-we-use-it/
          http://www.aygfsteel.com/sevenguin/archive/2011/04/20/348628.html

          轉:J2SE5中的最新注釋功能SuppressWarnings
          http://wenku.baidu.com/view/9d20440f844769eae009edf2.html
          實戰篇:設計自己的Annotation
          Supported Values for @SuppressWarnings
          主站蜘蛛池模板: 长岛县| 遂平县| 馆陶县| 亳州市| 喀喇| 富宁县| 藁城市| 含山县| 乌鲁木齐县| 吉林省| 大同市| 芜湖市| 绥芬河市| 兴国县| 乳山市| 虞城县| 栾川县| 安图县| 麦盖提县| 文山县| 道孚县| 浠水县| 静乐县| 盐池县| 临夏市| 南雄市| 绥中县| 鄂温| 甘孜| 平江县| 闻喜县| 汝阳县| 涿州市| 平邑县| 永川市| 巴里| 英吉沙县| 辽宁省| 甘南县| 秦皇岛市| 吉水县|