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) final class
A ClassVisitor that retrofits classes to 1.5 version.(package private) final class
A 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 String
The 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 String
The name of the module-info file.private static final Handle
Bootstrap method for the string concatenation using indy. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static void
checkPrivateMemberAccess
(List<ClassReader> readers) Checks that no code accesses to a private member from another class.private void
generateModuleInfoClass
(Path dstDir, String version) getAllClasses
(Path path, boolean includeModuleInfo) private List
<ClassReader> getClassReaders
(List<Path> classFiles) private static boolean
isAsmModule
(String packageName) static void
Transforms the class files in the given directory, in place, in order to make them compatible with the JDK 1.5.private void
void
Transforms the class files in the given directory, in place, in order to make them compatible with the JDK 1.5.void
verify
(Path 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 void
verifyModuleInfoClass
(Path 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:
-
STRING_CONCAT_FACTORY_HANDLE
Bootstrap method for the string concatenation using indy. -
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(Path 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.
-
getClassReaders
- Throws:
IOException
-
getAllClasses
- Throws:
IOException
-
checkPrivateMemberAccess
Checks that no code accesses to a private member from another class. If there is a private access, removing the nestmate attributes is not a legal transformation. -
generateModuleInfoClass
- Throws:
IOException
-
verifyModuleInfoClass
private void verifyModuleInfoClass(Path dstDir, String expectedVersion, Set<String> expectedExports, Set<String> expectedRequires) throws IOException - Throws:
IOException
-
isAsmModule
-
readJdkApi
- Throws:
IOException
-