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

Some package names in Deployment Descriptor are not transformed.

tsyamamoto opened this issue · comments

Environment Details

  • Transformer Version: 63e9d18
  • JDK version: 11
  • OS: Windows Server 2019, Red Hat Enterprise Linux 7.9

Problem Description

Some package names in Deployment Descriptor are not transformed.

Steps to reproduce

The problem occurs when a Jakarta EE related file such as following examples are given as the input of Transformer.

  • Example 1: ejb-jar.xml
    <container-transaction>
      <method>
        <ejb-name>myejb</ejb-name>
        <method-name>onMessage</method-name>
        <method-params>
          <method-param>javax.jms.Message</method-param>
        </method-params>
      </method>
      <trans-attribute>Required</trans-attribute>
    </container-transaction>
  • Example 2: .tld
    <function>
        <name>getId</name>
        <function-class>test.MyFunctions</function-class>
        <function-signature>
            java.lang.String getId(javax.servlet.http.HttpServletRequest)
        </function-signature>
    </function>
    <function>
        <name>getId2</name>
        <function-class>test.MyFunctions</function-class>
        <function-signature>
            java.lang.String getId2(javax.servlet.http.HttpSession)
        </function-signature>
    </function>
  • Example 3: ra.xml
        <authentication-mechanism>
           <description>auto mechanism</description>
            <authentication-mechanism-type>BasicPassword</authentication-mechanism-type>
            <credential-interface>javax.resource.spi.security.GenericCredential</credential-interface>
        </authentication-mechanism>

Cause

Currently, the JakartaEE class name translation table jakarta-renames.properties only applies to some DeploymentDescriptors, such as web.xml.

*.tag=jakarta-direct.properties,jakarta-renames.properties
*.taglib.xml=jakarta-renames.properties
*.tld=jakarta-direct.properties
application.xml=jakarta-application-xml.properties,jakarta-direct.properties
application-client.xml=jakarta-application-xml.properties,jakarta-direct.properties
beans.xml=jakarta-beans-xml.properties,jakarta-direct.properties
ejb-jar.xml=jakarta-ejb-jar-xml.properties,jakarta-direct.properties
glassfish-*.xml=jakarta-direct.properties
permissions.xml=jakarta-permissions-xml.properties,jakarta-direct.properties
persistence.xml=jakarta-persistence-xml.properties,jakarta-direct.properties
ra.xml=jakarta-ra-xml.properties,jakarta-direct.properties
validation.xml=jakarta-direct.properties

How about adding jakarta-renames.properties to jakarta-text-master.properties just like web.xml so that Jakarta EE class names in these Deployment Descriptors are also converted by default?
Since it is difficult to enumerate all classes that may be listed in Deployment Descriptor, listing the classes that need to be converted individually in jakarta-direct.properties may cause the leakage as described above.
For this reason, I think that jakarta-renames.properties should be applied when converting all Jakarta EE Deployment Descriptors.

*.tag=jakarta-direct.properties,jakarta-renames.properties
*.taglib.xml=jakarta-renames.properties
*.tld=jakarta-direct.properties,jakarta-renames.properties

application.xml=jakarta-application-xml.properties,jakarta-direct.properties,jakarta-renames.properties
application-client.xml=jakarta-application-xml.properties,jakarta-direct.properties,jakarta-renames.properties
beans.xml=jakarta-beans-xml.properties,jakarta-direct.properties,jakarta-renames.properties
ejb-jar.xml=jakarta-ejb-jar-xml.properties,jakarta-direct.properties,jakarta-renames.properties
glassfish-*.xml=jakarta-direct.properties,jakarta-renames.properties
permissions.xml=jakarta-permissions-xml.properties,jakarta-direct.properties,jakarta-renames.properties
persistence.xml=jakarta-persistence-xml.properties,jakarta-direct.properties,jakarta-renames.properties
ra.xml=jakarta-ra-xml.properties,jakarta-direct.properties,jakarta-renames.properties
validation.xml=jakarta-direct.properties,jakarta-renames.properties
web.xml=jakarta-web-xml.properties,jakarta-direct.properties,jakarta-renames.properties
web-fragment.xml=jakarta-web-xml.properties,jakarta-direct.properties,jakarta-renames.properties
faces-config.xml=jakarta-faces-config-xml.properties,jakarta-direct.properties,jakarta-renames.properties
*.faces-config.xml=jakarta-faces-config-xml.properties,jakarta-direct.properties,jakarta-renames.properties
UTService.xml=jakarta-direct.properties
TransactionManager.xml=jakarta-direct.properties

Note that both jakarta-renames.properties and jakarta-direct.properties are applied if target file is xml file which is not in jakarta-text-master.properties, such as "other.xml".

example) other.xml

<?xml version='1.0' encoding='UTF-8'?>
<foo>
    <function>
        <function-name>test</function-name>
        <function-class>javax.servlet.http.HttpServlet</function-class>
        <function-signature>void writeSource(javax.faces.context.FacesContext,java.lang.String)</function-signature>
        <properties>
          <property name="javax.servlet.request.cipher_suite" value="SHA256">
        </properties>
    </function>
</foo>>

This is because XmlActionImpl has been applied.

# java -jar src/resources/transformer/org.eclipse.transformer.cli-0.5.0-SNAPSHOT.jar src/resources/apptype/006/other/other.xml /tmp/output_other.xml
-snip-
[main] INFO Transformer - Text files will be updated
[main] INFO Transformer - Java direct string updates will be performed
[main] INFO Transformer - All resources will be selected
[main] INFO Transformer - Action selected for input [ src/resources/apptype/006/other/other.xml ]: XML Action
[main] INFO Transformer - Input  [ src/resources/apptype/006/other/other.xml ] as [ /root/src/resources/apptype/006/other/other.xml ]
[main] INFO Transformer - Output [ src/resources/apptype/006/other/other.xml ] as [ /tmp/output_other.xml ]
[main] INFO Transformer - [ Content changes ]: [ 3 ]
[main] INFO Transformer - Transformer Return Code [ 0 ] [ Success ]

This results in a strange situation where the javax package name in the Jakarta EE Deployment Descriptor is not converted, but the javax package name in the XML file that is not the Jakarta EE Deployment Descriptor is converted.
However, we cannot apply XmlActionImpl to Jakarta EE Deployment Descriptors because we must change the version of the schema in the Jakarta EE Deployment Descriptors.

(#323 will be reproduced)

Impact of Issue

Since they are commonly used by Jakarta EE, it would be very inconvenient if they are not converted by default.

I made a further change in #343 which removed some rules from master text since they will be covered by XmlActionImpl. Please confirm that change is not an issue for you.