`slice2java` Should Place `@Generated` Annotation on Generated Code
Java has support for an annotation to mark code as 'generated': https://docs.oracle.com/en/java/javase/17/docs/api/java.compiler/javax/annotation/processing/Generated.html
If adding this annotation to the generated code is straightforward and doesn't break anything, we should have slice2java generate this in place of the // <auto-generated> comment it currently generates.
I assume we would put this attribute on generated types. And it would not replace the comment-header in the generated files.
Yes, I mistakenly thought that this could be applied at a file-level, but it can't. Indeed, we'd generate it on each of the generated types.
I'm no longer convinced this is worth doing.
In Java8, this annotation was javax.annotation.Generated, but in Java9+ it was moved into javax.annotation.processing.Generated.
And it seems like this type would require users to add requires java.compiler; to their module-info file.
I don't think putting this onus on users is worth the incredibly small benefit of properly using @Generated.
Here's the full error you get without require java.compiler;:
/Users/austin/Code/zeroc/ice/java/src/com.zeroc.ice/build/generated/source/slice/main/com/zeroc/Ice/SSLEndpointType.java:11: error: package javax.annotation.processing is not visible
@javax.annotation.processing.Generated(value = "slice2java")
^
(package javax.annotation.processing is declared in module java.compiler, but module com.zeroc.ice does not read it)
What do other compilers do?
The code-gen tools that still generate @Generated all use 3rd party versions like @jakarta.annotation.Generated or @com.google.protobuf.Generated. So, we could follow suit and offer our own @com.zeroc.Slice.Generated, but I don't think it's worth the effort.