wildfly-extras / batavia Goto Github PK
View Code? Open in Web Editor NEWLicense: Apache License 2.0
License: Apache License 2.0
Currently, the API uses the java.io.File, making it harder to use for example with a remote JAR without having to persist it on the disk to transform or use as a Java agent.
Would this be possible or there are some major issues with the all in-memory approach?
To reproduce from wildfly/dist/target/wildfly-20.0.0.Final-SNAPSHOT/modules/system/layers/base/org/bouncycastle/main:
ee8jar2ee9.sh bcprov-jdk15on-1.65.jar /tmp
inputs:
jarname=bcprov-jdk15on-1.65.jar /tmp
Exception in thread "main" java.lang.UnsupportedOperationException: This feature requires ASM7
at org.objectweb.asm.ClassVisitor.visitNestHost(ClassVisitor.java:150)
at org.objectweb.asm.ClassReader.accept(ClassReader.java:550)
at org.objectweb.asm.ClassReader.accept(ClassReader.java:400)
at org.wildfly.transformer.asm.TransformerImpl.transform(TransformerImpl.java:99)
at org.wildfly.transformer.asm.TransformerImpl.transform(TransformerImpl.java:627)
at org.wildfly.transformer.tool.api.ToolUtils.transformJarFile(ToolUtils.java:104)
at org.wildfly.transformer.tool.cli.Main.main(Main.java:45)
servlet/src/main/java/io/undertow/servlet/handlers/security/SSLInformationAssociationHandler.java contains:
"javax.servlet.request.cipher_suite"
"javax.servlet.request.key_size"
"javax.servlet.request.ssl_session_id"
"javax.servlet.request.X509Certificate"
These constants must be transformed to jakarta namespace.
JAXB includes a couple properties used to resolve interface implementations whose values have changed:
https://github.com/eclipse-ee4j/jaxb-api/blob/master/jaxb-api/src/main/java/jakarta/xml/bind/JAXBContext.java#L308
https://github.com/eclipse-ee4j/jaxb-api/blob/master/jaxb-api/src/main/java/jakarta/xml/bind/ContextFinder.java#L42
These are used to resolve by checking system properties, which is out of scope for batavia, but also using jaxb.properties files on the classpath, which are in scope.
Two cases that should be handled:
javax
instead of jakarta
javax.faces.source
) of the AJAX request. Those occurences are also not replaced.No Idea how to fix that properly. Affected files might be java, xhtml, js.
Some projects may wish to customize the javax -> jakarta or jakarta -> javax transformation process.
We should provide an API that will allow this and have it configurable via our tools (maven, cmdline).
Tried to transform test.zip and note that the following line doesn't get transformed:
#591 invokestatic org/wildfly/extension/elytron/ElytronDefinition.lambda$registerAuthConfigFactory$0:(Ljavax/security/auth/message/config/AuthConfigFactory;)Ljava/lang/Void;
The above is part of:
InnerClasses:
static #263; //class org/wildfly/extension/elytron/ElytronDefinition$3
#181; //class org/wildfly/extension/elytron/ElytronDefinition$2
#175; //class org/wildfly/extension/elytron/ElytronDefinition$1
public static final #273= #272 of #610; //AttachmentKey=class org/jboss/as/controller/OperationContext$AttachmentKey of class org/jboss/as/controller/OperationContext
public static #388= #9 of #265; //Parameters=class org/jboss/as/controller/SimpleResourceDefinition$Parameters of class org/jboss/as/controller/SimpleResourceDefinition
public static #645= #238 of #643; //Builder=class org/jboss/as/controller/StringListAttributeDefinition$Builder of class org/jboss/as/controller/StringListAttributeDefinition
public static #645= #257 of #666; //Builder=class org/jboss/as/controller/PropertiesAttributeDefinition$Builder of class org/jboss/as/controller/PropertiesAttributeDefinition
public static final #825= #586 of #614; //Mode=class org/jboss/msc/service/ServiceController$Mode of class org/jboss/msc/service/ServiceController
public static abstract #645= #900 of #918; //Builder=class org/jboss/as/controller/ListAttributeDefinition$Builder of class org/jboss/as/controller/ListAttributeDefinition
public static final #923= #922 of #928; //Lookup=class java/lang/invoke/MethodHandles$Lookup of class java/lang/invoke/MethodHandles
SourceFile: "ElytronDefinition.java"
BootstrapMethods:
0: #427 invokestatic java/lang/invoke/LambdaMetafactory.metafactory:(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodHandle;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite;
Method arguments:
#428 (Ljava/lang/Object;)Ljava/lang/Object;
#429 invokestatic org/wildfly/extension/elytron/capabilities/_private/SecurityEventListener.from:(Ljava/util/function/Consumer;)Lorg/wildfly/extension/elytron/capabilities/_private/SecurityEventListener;
#430 (Ljava/util/function/Consumer;)Lorg/wildfly/extension/elytron/capabilities/_private/SecurityEventListener;
1: #427 invokestatic java/lang/invoke/LambdaMetafactory.metafactory:(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodHandle;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite;
Method arguments:
#590 ()Ljava/lang/Object;
#591 invokestatic org/wildfly/extension/elytron/ElytronDefinition.lambda$registerAuthConfigFactory$0:(Ljavax/security/auth/message/config/AuthConfigFactory;)Ljava/lang/Void;
#592 ()Ljava/lang/Void;
https://eclipse-ee4j.github.io/jakartaee-platform/jakartaee9/JakartaEE9ReleasePlan mentions that JAXB/Jakarta XML Binding (Optional) classes need to be changed to the jakarta namespace.
e.g.
<o:converter converterId="javax.faces.Number" [...] />
Got it working with the following changes:
jakarta-txt-master.properties
*.xhtml=xhtml-renames.properties
xhtml-renames.properties (new file)
javax.faces.BigDecimal=jakarta.faces.BigDecimal
javax.faces.BigInteger=jakarta.faces.BigInteger
javax.faces.Boolean=jakarta.faces.Boolean
javax.faces.Byte=jakarta.faces.Byte
javax.faces.Character=jakarta.faces.Character
javax.faces.DateTime=jakarta.faces.DateTime
javax.faces.Double=jakarta.faces.Double
javax.faces.Enum=jakarta.faces.Enum
javax.faces.Float=jakarta.faces.Float
javax.faces.Integer=jakarta.faces.Integer
javax.faces.Long=jakarta.faces.Long
javax.faces.Number=jakarta.faces.Number
javax.faces.Short=jakarta.faces.Short
Most probably there could be a better solution for that? Additionally it does not handle cases when a converter is resolved programmatically in java.
Currently, if the input is signed (e.g. bouncycastle signed jar), the transformer should either generate a warning that the output will not be signed. I don't think it should be considered a cause for failing the transformation but that could be another option (with perhaps a command line option to override the failure, so that the user acknowledges that the output is not going to be signed.
Update https://github.com/wildfly-extras/batavia/blob/master/impl/ecl/src/main/resources/org/wildfly/transformer/eclipse/jakarta-direct.properties to replace the strings that Jastow uses to generate java classes from JSPs. Add properties for the static strings that remain once https://issues.redhat.com/browse/UNDERTOW-1768 is done.
Currently it is difficult to transform a source tree but override a few of the transformed files with normal files in src/[main|test]/java in the target maven project. This is because (IIRC) the transformed source ends up being compiled, not the normal source.
Enhancement is to add some kind of exclusion setting to the plugin config such that files that match the configured settings don't get transformed and don't get written to the target dir.
This should be reasonably straightforward as the mojo walks the source tree and transforms files one at a time, so applying a check against the config before doing that should work fine.
Need to better understand how to support org.objectweb.asm.ConstantDynamic and what we need to do exactly for them at runtime.
Description from the ConstanceDynamic class:
A constant whose value is computed at runtime, with a bootstrap method.
Both "no dependencies" transformer and "asm-based" transformer don't remap transformed classes to appropriate packages. This causes issues with JBoss modules framework where module metadata are generated according to detected packages in particular jar file.
I have a custom JSF resource handler (ResourceHandlerWrapper
) which uses ResourceHandler.RESOURCE_IDENTIFIER
. The contents of that constant is currently not updated in die class files in WildFly 24 Beta1.
I've modified the file impl/ecl/src/main/resources/org/wildfly/extras/transformer/eclipse/jakarta-direct.properties
and added the following line:
/javax.faces.resource=/jakarta.faces.resource
That fixed it for me.
We missed handling:
jar tf jakarta.jakartaee-api-9.0.0-RC1.jar | grep activation
jakarta/activation/
jakarta/activation/DataSource.class
jakarta/activation/DataHandler$1.class
jakarta/activation/DataHandler.class
jakarta/activation/CommandMap.class
jakarta/activation/ActivationDataFlavor.class
jakarta/activation/DataContentHandler.class
jakarta/activation/DataContentHandlerFactory.class
jakarta/activation/CommandInfo$Beans$1.class
jakarta/activation/CommandInfo$Beans.class
jakarta/activation/CommandInfo.class
jakarta/activation/MimeType.class
jakarta/activation/MimeTypeParameterList.class
jakarta/activation/MimeTypeParseException.class
jakarta/activation/UnsupportedDataTypeException.class
jakarta/activation/MailcapCommandMap$1.class
jakarta/activation/MailcapCommandMap.class
jakarta/activation/MimetypesFileTypeMap$1.class
jakarta/activation/MimetypesFileTypeMap.class
jakarta/activation/FileTypeMap.class
jakarta/activation/SecuritySupport$1.class
jakarta/activation/SecuritySupport$2.class
jakarta/activation/SecuritySupport$3.class
jakarta/activation/SecuritySupport$4.class
jakarta/activation/SecuritySupport$5.class
jakarta/activation/SecuritySupport.class
jakarta/activation/URLDataSource.class
jakarta/activation/FileDataSource.class
jakarta/activation/CommandObject.class
jakarta/activation/DataHandlerDataSource.class
jakarta/activation/DataSourceDataContentHandler.class
jakarta/activation/ObjectDataContentHandler.class
It would be convenient to have overwrite option that deletes the outJarFile if it exists already, previous to call to createNewFile. No need to respond, if you agree we could create an issue for that. When I have used Batava or Eclipse Transformer to run the same script repeatedly, it is a pain to have to ensure the output doesn't exist.
Need to also handle transforming the javax.json => jakarta.json in:
mv.visitFrame(Opcodes.F_FULL, 3, new Object[] {"org/jboss/logmanager/formatters/JsonFormatter", "java/io/Writer", "javax/json/stream/JsonGeneratorFactory"}, 0, new Object[] {});
It should be possible to configure which packages or classes should be transformed or not.
We should allow this via our API and filtering should support:
We can see some test failures due to fact some javax classes are invoked via java reflection.
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException
at java.lang.System.arraycopy(Native Method)
at org.wildfly.transformer.nodeps.TransformerImpl.applyPatches(TransformerImpl.java:253)
at org.wildfly.transformer.nodeps.TransformerImpl.transform(TransformerImpl.java:191)
at org.wildfly.transformer.nodeps.TransformerImpl.transform(TransformerImpl.java:116)
at org.wildfly.transformer.tool.shared.Common.transformJarFile(Common.java:89)
at org.wildfly.transformer.tool.cmdline.Main.main(Main.java:45)
Steps to reproduce to be added here.
Both ASM transformer and No-Dependencies transformer are generating 'reflection' helper classes with wrong package for classes that will be moved to different package (according to transformation rules).
Steps to reproduce:
Run ASM or No-Dependencies transformer against servlet-api-2.3 jar with javax/servlet -> jakarta/servlet rename rule.
There will be javax package in transformed jar and it shouldn't be there.
Jakarta XML Binding 3.0 specifies a new http://jakarta.ee/xml/ns/jaxb namespace to replace the old http://java.sun.com/xml/ns/jaxb one. Use of this ns is tested in the Jakarta XML Binding 3.0 TCK and class files written for EE 8 need to be transformed to use it. Code that's been transformed that way does not understand the old namespace (changing that is a separate issue for other projects) so for existing documents to work we also need to transform that string in .xsd, .xjb and .rng files.
See https://tomcat.apache.org/tomcat-9.0-doc/servletapi/constant-values.html for list of all constants we should transform.
Libraries other than Jakarta Annotations, particularly JSR 305 / com.google.code.findbugs:jsr305, utilize the javax.annotation root package. This means we can't safely transform Jakarta Annotations based on the package name alone.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.