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 Details

    • logger

      private static final Logger logger
    • sm

      private static final StringManager sm
    • profile

      protected final EESpecProfile profile
      The configured spec profile.
  • Constructor Details

    • 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 Details

    • toString

      public String toString()
      Overrides:
      toString in class Object
    • accepts

      public boolean accepts(String filename)
      Description copied from interface: Converter
      Check if the file can be processed by this converter.
      Specified by:
      accepts in interface Converter
      Parameters:
      filename - the file name
      Returns:
      true if the converter will process this file
    • convert

      public boolean convert(String path, InputStream src, OutputStream dest, EESpecProfile profile) throws IOException
      Description copied from interface: Converter
      Copies the source to the destination, converting it if necessary, according to the requirements of the given profile.
      Specified by:
      convert in interface Converter
      Parameters:
      path - The path to the data being converted
      src - The source data to convert
      dest - The destination to write the converted data
      profile - 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:
      transform in interface ClassFileTransformer
      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 path
      src - the source byte stream
      dest - the output byte stream
      profile - the specification profile to use
      loader - the class loader
      Returns:
      true if conversion occurred
      Throws:
      IOException - rethrow on byte read or write