Package org.objectweb.asm.tools
Class Retrofitter
java.lang.Object
org.objectweb.asm.tools.Retrofitter
A tool to transform classes in order to make them compatible with Java 1.5, and to check that
they use only the JDK 1.5 API and JDK 1.5 class file features. The original classes can either be
transformed "in place", or be copied first to destination directory and transformed here (leaving
the original classes unchanged).
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) classA ClassVisitor that retrofits classes to 1.5 version.(package private) classA ClassVisitor checking that a class uses only JDK 1.5 class file features and the JDK 1.5 API. -
Field Summary
FieldsModifier and TypeFieldDescriptionThe internal names of the packages exported by the retrofitted classes.The internal names of the packages imported by the retrofitted classes.private static final StringThe name of the java.base module.The fields and methods of the JDK 1.5 API.The class hierarchy of the JDK 1.5 API.private static final StringThe name of the module-info file. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voidgenerateModuleInfoClass(File dstDir, String version) getAllClasses(File file, List<File> allClasses) private static booleanisAsmModule(String packageName) static voidTransforms the class files in the given directory, in place, in order to make them compatible with the JDK 1.5.private voidvoidTransforms the class files in the given directory, in place, in order to make them compatible with the JDK 1.5.voidverify(File classesDir, String expectedVersion, List<String> expectedExports, List<String> expectedRequires) Verify that the class files in the given directory only use JDK 1.5 APIs, and that a module-info class is present with the expected content.private voidverifyModuleInfoClass(File dstDir, String expectedVersion, Set<String> expectedExports, Set<String> expectedRequires)
-
Field Details
-
MODULE_INFO
The name of the module-info file.- See Also:
-
JAVA_BASE_MODULE
The name of the java.base module.- See Also:
-
jdkApi
The fields and methods of the JDK 1.5 API. Each string has the form "<owner><name><descriptor>". -
jdkHierarchy
The class hierarchy of the JDK 1.5 API. Maps each class name to the name of its super class. -
exports
The internal names of the packages exported by the retrofitted classes. -
imports
The internal names of the packages imported by the retrofitted classes.
-
-
Constructor Details
-
Retrofitter
public Retrofitter()
-
-
Method Details
-
main
Transforms the class files in the given directory, in place, in order to make them compatible with the JDK 1.5. Also generates a module-info class in this directory, with the given module version.- Parameters:
args- a directory containing compiled classes and the ASM release version.- Throws:
IOException- if a file can't be read or written.
-
retrofit
Transforms the class files in the given directory, in place, in order to make them compatible with the JDK 1.5. Also generates a module-info class in this directory, with the given module version.- Parameters:
classesDir- a directory containing compiled classes.version- the module-info version.- Throws:
IOException- if a file can't be read or written.
-
verify
public void verify(File classesDir, String expectedVersion, List<String> expectedExports, List<String> expectedRequires) throws IOException Verify that the class files in the given directory only use JDK 1.5 APIs, and that a module-info class is present with the expected content.- Parameters:
classesDir- a directory containing compiled classes.expectedVersion- the expected module-info version.expectedExports- the expected module-info exported packages.expectedRequires- the expected module-info required modules.- Throws:
IOException- if a file can't be read.IllegalArgumentException- if the module-info class does not have the expected content.
-
getAllClasses
- Throws:
IOException
-
generateModuleInfoClass
- Throws:
IOException
-
verifyModuleInfoClass
private void verifyModuleInfoClass(File dstDir, String expectedVersion, Set<String> expectedExports, Set<String> expectedRequires) throws IOException - Throws:
IOException
-
isAsmModule
-
readJdkApi
- Throws:
IOException
-