是否有与 MISRA C 等效的 Java?

发布于 2024-11-08 14:19:53 字数 134 浏览 0 评论 0原文

在某些语言中,有规则/最佳实践/等。促进软件安全、确保预期的运行时行为等。我想到的两个是用于 C/C++ 的 MISRA 和用于 Ada 的 Ravenscar 配置文件。如果您的代码遵循这些标准,通常会给您一种温暖模糊的感觉。 Java有这样的标准吗?

In some languages, there are rules/best practices/etc. that promote software safety, ensure expected runtime behavior, etc. Two that come to mind are MISRA for C/C++, and the Ravenscar profile for Ada. There is typically a warm fuzzy feeling about your code if it is stamped as following these standards. Is there any such standard for Java?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

给我一枪 2024-11-15 14:19:53

我认为 Java 没有像 MISRA C/C++ 最佳实践这样的东西,而且我认为对于像 Java 这样的语言来说也没有必要,因为它不像 C 和 C++ 那样有那么多未定义或未指定行为的角落有。 Java 中缺乏显式指针以及数组索引的边界始终由运行时检查等特性使 Java 成为比 C 或 C++ 更安全的语言。

大多数 Java 开发人员似乎都遵循一个通用的编码标准:代码约定对于 Java 编程语言,但这更多的是一种风格指南,而不是最佳实践指南。

有一些很好的、众所周知的 Java 静态代码分析工具:FindBugsPMD,它将检查您的代码是否存在可能危险的结构或不良做法。

如果您想了解 Java 中的潜在陷阱,那么强烈推荐两本书: Effective Java Java Puzzlers

其他类似的资源包括:

I don't think there is something like the MISRA C/C++ best practices for Java, and I think it is also less necessary with a language like Java because it doesn't have as many corners of undefined or unspecified behaviour like C and C++ have. Features such as the lack of explicit pointers in Java and the fact that the bounds of array indices are always checked by the runtime make Java a safer language than C or C++.

There is a common coding standard that most Java developers seem to follow: Code Conventions for the Java Programming Language, but that is more a style guide than a best practices guide.

There are a few good and well-known static code analysis tools for Java: FindBugs and PMD for example, which will check your code for possibly dangerous constructions or bad practices.

If you want to learn about the potential pitfalls in Java, then two books are highly recommended: Effective Java and Java Puzzlers.

Additional, similar resources include:

昇り龍 2024-11-15 14:19:53

目前,还没有 MISRA Java,也没有任何立即创建 MISRA Java 的计划。

MISRA 技术委员会已对该主题进行了几次简短讨论,但在没有任何需求(和/或志愿者参与该主题)的情况下,这种情况不太可能发生。

更新:六年过去了……

这个问题在我担任演讲者的会议上被多次提出,通常得到了观众的广泛支持。我总是通过询问愿意成为委员会成员的观众来回答...这让房间安静下来:(

TL;DR:如果有足够多的志愿者挺身而出,我们就会这么做!

[以个人身份发布,尽管MISRA 技术委员会成员]

--- 2023 年 7 月更新 ---

我们不再被问及 MISRA Java,但当然 MISRA Rust 是最新的建议

这同样适用:如果有足够多的志愿者挺身而出,我们可能会这样做。 。

Currently, there is no MISRA Java - nor any immediate plans to create one.

The topic has been discussed briefly a couple of times by the MISRA Technical Board, but in the absence of any demand (and/or volunteers to work on it) it is unlikely to happen.

Update: Six years on...

This question has been asked several times, at Conferences that I have been a speaker at, usually with broad support from the audience. I always reply by asking the audience who'll volunteer to be part of the committee... which silences the room :(

TL;DR: If enough volunteers come forward, we'll do it!

[Posted in a personal capacity, albeit a MISRA Tech Board member]

--- Update July 2023 ---

We're no longer being asked about MISRA Java, but of course MISRA Rust is the latest suggestion.

The same applies: if enough volunteers come forward, we may do it.

漫漫岁月 2024-11-15 14:19:53

SEI CERT:

Java 编码指南包括 Java 标准版 7 平台环境中安全编程的推荐实践。这是一项正在进行的工作,我们积极寻求您的反馈和参与,以使这项工作取得成功。我们感谢并感谢所有贡献者。

https://www.securecoding.cert.org/confluence/display /jg/Java+编码+指南

SEI CERT:

The Java Coding Guidelines includes recommended practices for secure programming in the Java Standard Edition 7 Platform environment. This is a work in progress, and we actively seek your feedback and involvement in making this effort a success. We thank and acknowledge all of the contributors.

https://www.securecoding.cert.org/confluence/display/jg/Java+Coding+Guidelines

熊抱啵儿 2024-11-15 14:19:53

对于关注此主题的人来说,有一个正在进行的开放安全关键 JAVA (oSCJ) 计划,该计划正在为安全关键应用程序 (JSR-302) 定义 JAVA 语言的子集。
http://jcp.org/en/jsr/detail?id=302

For those following this thread, there is a Open Safety Critical JAVA (oSCJ) initiative going-on, which is defining a subset of the JAVA language for Safety-Critical Applications (JSR-302).
http://jcp.org/en/jsr/detail?id=302

遗心遗梦遗幸福 2024-11-15 14:19:53

有本书叫《代码大全》。这是由一位曾在 Microsoft 工作过的程序员编写的,并且还具有使用 2/3 种不同高级语言进行专业软件开发的知识。除了 MISRA C++ 之外,我还使用这本书。 《Code Complete》是一本独立于语言的书,有助于塑造您的专业软件工程实践。

There is a book called "Code Complete". This is written by a programmer who has worked for Microsoft and also has knowledge in professional software development using 2/3 different high-level languages. I use this book besides MISRA C++. "Code Complete" is a language independent book and helpful to shape your professional software engineering practices.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文