211java基础教学

211java基础教学Summary As of Java SE 8 java compilers are required by reasonable interpretati of the Java Language Specificatio to issue deprecation warnings when a deprecated type is imported by name or

大家好,我是讯享网,很高兴认识大家。



Summary

As of Java SE 8, java compilers are required by reasonable interpretations of the Java Language Specification to issue deprecation warnings when a deprecated type is imported by name or when a deprecated member (method, field, nested type) is imported statically. These warnings are uninformative and should not be required. Deprecation warnings at actual uses of deprecated members should remain.

Goals

The goal of this JEP is to facilitate making large code bases clean of lint warnings. The deprecation warnings on imports cannot be suppressed using the annotation, unlike uses of deprecated members in code. In large code bases like that of the JDK, deprecated functionality must often be supported for some time and merely importing a deprecated construct does not justify a warning message if all the uses of the deprecated construct are intentional and suppressed.

Non-Goals

It is not a goal of this JEP to actually resolve all the deprecation warnings in the JDK code case. However, that might occur as part of a separate 211java基础教学 maintenance effort in JDK 9.

Description

From a specification perspective, the needed change is small. In JLS 8 the section on states:

A Java compiler must produce a deprecation warning when a type, method, field, or constructor whose declaration is annotated with is used (overridden, invoked, or referenced by name) in a construct which is explicitly or implicitly declared, unless:

  • The use is within an entity that is itself annotated with the annotation ; or
  • The use is within an entity that is annotated to suppress the warning with the annotation ; or
  • The use and declaration are both within the same outermost class.

The specification change would be something like adding another bullet stating the additional exclusion:

  • The use is within an statement.

In the reference implementation, there would be a simple check to skip over import statements when looking for deprecation warnings.

Testing

小讯
上一篇 2024-12-24 13:43
下一篇 2025-01-02 17:43

相关推荐

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容,请联系我们,一经查实,本站将立刻删除。
如需转载请保留出处:https://51itzy.com/kjqy/7903.html