如何让string.format在编译时抱怨 [英] How to get string.format to complain at compile time

查看:141
本文介绍了如何让string.format在编译时抱怨的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

编译器可以访问格式字符串AND所需的类型和参数。所以我假设有一些方法可以指出varargs的缺失参数,即使只是一个案例的一个子集。有没有一些eclipse或另一个ide表示传递的varargs可能会在运行时引起问题?

The compiler has access to the format string AND the required types and parameters. So I assume there would be some way to indicate missing parameters for the varargs ... even if only for a subset of cases. Is there someway for eclipse or another ide to indicate that the varargs passed might cause a problem at runtime ?

推荐答案

看起来好像FindBugs可以解决您的问题。有一些与格式字符串相关的警告类别。

It looks as if FindBugs can solve your problem. There are some warning categories related to format strings.

  • http://www.google.com/search?q=%2Bjava+%2Bprintf+%2Bfindbugs
  • http://findbugs.sourceforge.net/bugDescriptions.html#VA_FORMAT_STRING_MISSING_ARGUMENT

这篇关于如何让string.format在编译时抱怨的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆