When using the same JDK (i.e. the same javac executable), are the generated class files always identical? Can there be a difference depending on the
Overall, I'd have to say there is no guarantee that the same source will produce the same bytecode when compiled by the same compiler but on a different platform.
I'd look into scenarios involving different languages (code-pages), for example Windows with Japanese language support. Think multi-byte characters; unless the compiler always assumes it needs to support all languages it might optimize for 8-bit ASCII.
There is a section on binary compatibility in the Java Language Specification.
Within the framework of Release-to-Release Binary Compatibility in SOM (Forman, Conner, Danforth, and Raper, Proceedings of OOPSLA '95), Java programming language binaries are binary compatible under all relevant transformations that the authors identify (with some caveats with respect to the addition of instance variables). Using their scheme, here is a list of some important binary compatible changes that the Java programming language supports:
•Reimplementing existing methods, constructors, and initializers to improve performance.
•Changing methods or constructors to return values on inputs for which they previously either threw exceptions that normally should not occur or failed by going into an infinite loop or causing a deadlock.
•Adding new fields, methods, or constructors to an existing class or interface.
•Deleting private fields, methods, or constructors of a class.
•When an entire package is updated, deleting default (package-only) access fields, methods, or constructors of classes and interfaces in the package.
•Reordering the fields, methods, or constructors in an existing type declaration.
•Moving a method upward in the class hierarchy.
•Reordering the list of direct superinterfaces of a class or interface.
•Inserting new class or interface types in the type hierarchy.
This chapter specifies minimum standards for binary compatibility guaranteed by all implementations. The Java programming language guarantees compatibility when binaries of classes and interfaces are mixed that are not known to be from compatible sources, but whose sources have been modified in the compatible ways described here. Note that we are discussing compatibility between releases of an application. A discussion of compatibility among releases of the Java SE platform is beyond the scope of this chapter.