Is There a Java Equivalent to MISRA C?

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.


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]

Tags:

Java

Misra