智能客服
你问我答,随时在线为你解决问题

























您当前正在浏览HarmonyOS开发者3.0版本配套的开发者文档,对应API能力级别为API 8 Release。此版本文档已归档不再维护,推荐您使用HarmonyOS NEXT版本。
收起 自动换行 深色代码主题 复制 |
In addition to the usage restrictions imposed by its Target meta-annotation, compilers are required to implement additional usage restrictions on this annotation type; it is a compile-time error if a method or constructor declaration is annotated with a @SafeVarargs annotation, and either:
Compilers are encouraged to issue warnings when this annotation type is applied to a method or constructor declaration where:
- @SafeVarargs // Not actually safe!
- static void m(List<String>... stringLists) {
- Object[] array = stringLists;
- List<Integer> tmpList = Arrays.asList(42);
- array[0] = tmpList; // Semantically invalid, but compiles without warnings
- String s = stringLists[0].get(0); // Oh no, ClassCastException at runtime!
- }
-
Future versions of the platform may mandate compiler errors for such unsafe operations.
Since:
1.7智能客服
你问我答,随时在线为你解决问题
合作咨询
我们的专家服务团队将竭诚为您提供专业的合作咨询服务
解决方案
精准高效的一站式服务支持,助力开发者商业成功