Top Description Fields Constructors Methods
org.apache.tomcat.jakartaee

public Class ClassConverter

extends Object
implements Converter, ClassFileTransformer
Class Inheritance
All Implemented Interfaces
java.lang.instrument.ClassFileTransformer, org.apache.tomcat.jakartaee.Converter
Imports
java.io.ByteArrayInputStream, .ByteArrayOutputStream, .IOException, .InputStream, .OutputStream, java.lang.instrument.ClassFileTransformer, .IllegalClassFormatException, java.security.ProtectionDomain, java.util.logging.Level, .Logger, org.apache.bcel.classfile.ClassParser, .Constant, .ConstantUtf8, .JavaClass, org.apache.bcel.util.SyntheticRepository, org.apache.commons.io.IOUtils

Class converter and transformer.

Field Summary

Modifier and TypeField and Description
private static final Logger
protected final EESpecProfile
profile

The configured spec profile.

private static final StringManager

Constructor Summary

AccessConstructor and Description
public
ClassConverter()

Create a class converter with the default TOMCAT profile.

public
ClassConverter(EESpecProfile
the specification profile to use for conversion
profile
)

Create a class converter with the specified spec profile.

Method Summary

Modifier and TypeMethod and Description
public boolean
accepts(String
the file name
filename
)

Implements org.apache.tomcat.jakartaee.Converter.accepts.

Check if the file can be processed by this converter.
public boolean
convert(String
The path to the data being converted
path
,
InputStream
The source data to convert
src
,
OutputStream
The destination to write the converted data
dest
,
EESpecProfile
The profile that defines the conversion required
profile
)

Implements org.apache.tomcat.jakartaee.Converter.convert.

Copies the source to the destination, converting it if necessary, according to the requirements of the given profile.
protected boolean

Returns:

true if conversion occurred
convertInternal
(String
the path
path
,
InputStream
the source byte stream
src
,
OutputStream
the output byte stream
dest
,
EESpecProfile
the specification profile to use
profile
,
ClassLoader
the class loader
loader
)

Convert specified class bytecode.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
public byte[]
transform(ClassLoader
the defining loader of the class to be transformed, may be null if the bootstrap loader
loader
,
String
the name of the class in the internal form of fully qualified class and interface names as defined in The Java Virtual Machine Specification. For example, "java/util/List".
className
,
Class<?>
if this is triggered by a redefine or retransform, the class being redefined or retransformed; if this is a class load, null
classBeingRedefined
,
ProtectionDomain
the protection domain of the class being defined or redefined
protectionDomain
,
byte[]
the input byte buffer in class file format - must not be modified
classfileBuffer
)

Overrides default java.lang.instrument.ClassFileTransformer.transform.

Transforms the given class file and returns a new replacement class file.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

loggerback to summary
private static final Logger logger
profileback to summary
protected final EESpecProfile profile

The configured spec profile.

smback to summary
private static final StringManager sm

Constructor Detail

ClassConverterback to summary
public ClassConverter()

Create a class converter with the default TOMCAT profile.

ClassConverterback to summary
public ClassConverter(EESpecProfile profile)

Create a class converter with the specified spec profile.

Parameters
profile:EESpecProfile

the specification profile to use for conversion

Method Detail

acceptsback to summary
public boolean accepts(String filename)

Implements org.apache.tomcat.jakartaee.Converter.accepts.

Doc from org.apache.tomcat.jakartaee.Converter.accepts.

Check if the file can be processed by this converter.

Parameters
filename:String

the file name

Returns:boolean

true if the converter will process this file

Annotations
@Override
convertback to summary
public boolean convert(String path, InputStream src, OutputStream dest, EESpecProfile profile) throws IOException

Implements org.apache.tomcat.jakartaee.Converter.convert.

Doc from org.apache.tomcat.jakartaee.Converter.convert.

Copies the source to the destination, converting it if necessary, according to the requirements of the given profile.

Parameters
path:String

The path to the data being converted

src:InputStream

The source data to convert

dest:OutputStream

The destination to write the converted data

profile:EESpecProfile

The profile that defines the conversion required

Returns:boolean

true if the converter made a conversion to the file

Annotations
@Override
Exceptions
IOException:
If the conversion fails
convertInternalback to summary
protected boolean convertInternal(String path, InputStream src, OutputStream dest, EESpecProfile profile, ClassLoader loader) throws IOException

Convert specified class bytecode.

Parameters
path:String

the path

src:InputStream

the source byte stream

dest:OutputStream

the output byte stream

profile:EESpecProfile

the specification profile to use

loader:ClassLoader

the class loader

Returns:boolean

true if conversion occurred

Exceptions
IOException:
rethrow on byte read or write
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override
transformback to summary
public byte[] transform(ClassLoader loader, String className, Class<?> classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) throws IllegalClassFormatException

Overrides default java.lang.instrument.ClassFileTransformer.transform.

Doc from java.lang.instrument.ClassFileTransformer.transform.

Transforms the given class file and returns a new replacement class file. This method is invoked when the Module bearing transform is not overridden.

Parameters
loader:ClassLoader

the defining loader of the class to be transformed, may be null if the bootstrap loader

className:String

the name of the class in the internal form of fully qualified class and interface names as defined in The Java Virtual Machine Specification. For example, "java/util/List".

classBeingRedefined:Class<?>

if this is triggered by a redefine or retransform, the class being redefined or retransformed; if this is a class load, null

protectionDomain:ProtectionDomain

the protection domain of the class being defined or redefined

classfileBuffer:byte[]

the input byte buffer in class file format - must not be modified

Returns:byte[]

a well-formed class file buffer (the result of the transform), or null if no transform is performed

Annotations
@Override
Exceptions
IllegalClassFormatException:
if the input does not represent a well-formed class file