In principle, a compiler could leave information about itself in a class file, as class files are extensible containers, build from named attributes.
However, the class file format is well documented and there are independent open source libraries and tools, like ASM, BCEL, or Javassist, which can be used to inspect compiled class files and their attributes, to find out, that no such additional attributes exist in class files created by the common compilers like javac
or ecj
.
Still, there are some differences in the code generated, e.g. by javac
or ecj
, which allows to find out which of these compilers has been used. For example, this answer discusses the code generated by javac
for “try-with-resource” statements, which differs significantly from the code generated by ecj
.
However, you can not tell javac
of OpenJDK and Oracle’s commercial JDK apart, simply because it’s the same compiler. I just verified this by comparing trees of compiled nontrivial class files, generated by OpenJDK and Oracle’s JDK. Not a single bit difference.
The differences between these two JDKs are the monitoring and profiling tools. Of course, you can not find out whether these tools have been used during an application development, but that’s nothing to worry anyway, as Oracle’s licence allows using their JDK for development. The use of these management tools in a production environment, is what is supposed to cost money.