eclipse / transformer

Eclipse Transformer provides tools and runtime components that transform Java binaries, such as individual class files and complete JARs and WARs, mapping changes to Java packages, type names, and related resource names.

Home Page:https://projects.eclipse.org/projects/technology.transformer

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Wrong transformation of JSR 305 annotations

jeanouii opened this issue · comments

Hi,

I found a case where some JSR 305 annotations get converted over to jakarta namespace. As far as I am aware of, they aren't part of the new jakarta namespace, so should not be converted by default.

Here is an example
https://github.com/google/guava/blob/master/guava/src/com/google/common/io/package-info.java

Transformer operates on a package basis with respect to changing package names. The javax.annotation package name is part of the Jakarta Annotations spec: https://jakarta.ee/specifications/annotations/1.3/apidocs/javax/annotation/package-summary.html.

It is unfortunate that javax.annotation package is not "sealed". But for the default Jakarta transformation rules, the Jakarta Annotation specification indicated that the javax.annotation package should be renamed to jakarta.annotation.

jakarta.annotation.Nullable and jakarta.annotation.Notnull were in the JSR 305 and got converted so they have their equivalent. But, how can I solve the other ones being wrongly converted?

I looked at the code, but private ClassTypeSignature transform(ClassTypeSignature inputType) {} does only provide the package so I can't even tweak the renames.properties with something custom for my case.

I don't think you can with transformer. It is designed for package-level renaming and assumes that packages are units managed in whole. javax.annotation is a bit of a mess with multiple "contributors" to the package.

Is there a way we could move them back to javax?
The replacePackage seems to only use the package to do the substitution. If we would get the entire FQCN that'd be possible, I don't think this is currently possible.

I don't think this is currently possible.

It is not possible since transformer is currently designed and implemented to operate at the package name level and not the type name level. Some non-trivial changes would be necessary to support renaming individual type names and/or exclude individual types from a package rename.

Closing also this one