Package org.apache.tomcat.jakartaee
Class ClassConverter
- java.lang.Object
-
- org.apache.tomcat.jakartaee.ClassConverter
-
- All Implemented Interfaces:
ClassFileTransformer,Converter
public class ClassConverter extends Object implements Converter, ClassFileTransformer
Class converter and transformer.
-
-
Field Summary
Fields Modifier and Type Field Description protected EESpecProfileprofileThe configured spec profile.
-
Constructor Summary
Constructors Constructor Description ClassConverter()Create a class converter with the default TOMCAT profile.ClassConverter(EESpecProfile profile)Create a class converter with the specified spec profile.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanaccepts(String filename)Check if the file can be processed by this converter.booleanconvert(String path, InputStream src, OutputStream dest, EESpecProfile profile)Copies the source to the destination, converting it if necessary, according to the requirements of the given profile.protected booleanconvertInternal(String path, InputStream src, OutputStream dest, EESpecProfile profile, ClassLoader loader)Convert specified class bytecode.StringtoString()byte[]transform(ClassLoader loader, String className, Class<?> classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer)-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.lang.instrument.ClassFileTransformer
transform
-
-
-
-
Field Detail
-
profile
protected final EESpecProfile profile
The configured spec profile.
-
-
Constructor Detail
-
ClassConverter
public ClassConverter()
Create a class converter with the default TOMCAT profile.
-
ClassConverter
public ClassConverter(EESpecProfile profile)
Create a class converter with the specified spec profile.- Parameters:
profile- the specification profile to use for conversion
-
-
Method Detail
-
accepts
public boolean accepts(String filename)
Description copied from interface:ConverterCheck if the file can be processed by this converter.
-
convert
public boolean convert(String path, InputStream src, OutputStream dest, EESpecProfile profile) throws IOException
Description copied from interface:ConverterCopies the source to the destination, converting it if necessary, according to the requirements of the given profile.- Specified by:
convertin interfaceConverter- Parameters:
path- The path to the data being convertedsrc- The source data to convertdest- The destination to write the converted dataprofile- The profile that defines the conversion required- Returns:
- true if the converter made a conversion to the file
- Throws:
IOException- If the conversion fails
-
transform
public byte[] transform(ClassLoader loader, String className, Class<?> classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) throws IllegalClassFormatException
- Specified by:
transformin interfaceClassFileTransformer- Throws:
IllegalClassFormatException
-
convertInternal
protected boolean convertInternal(String path, InputStream src, OutputStream dest, EESpecProfile profile, ClassLoader loader) throws IOException
Convert specified class bytecode.- Parameters:
path- the pathsrc- the source byte streamdest- the output byte streamprofile- the specification profile to useloader- the class loader- Returns:
- true if conversion occurred
- Throws:
IOException- rethrow on byte read or write
-
-