Show TOC Start of Content Area

Background documentation Web Dynpro Class File Minimizer  Locate the document in its SAP Library structure

Web Dynpro for Java automatically generates Java code to simplify access to otherwise generic structures like contexts or models and to enable typesafe access to data or Web Dynpro structures. This provides a higher level of safety at compile time and reduces the number of errors caused by typing mistakes. But, it often leads to a lot of classes that are used only partially: For example, not every attribute in a context node is accessed via application code. However, as all classes are internally referenced by the application, they must all be loaded into the Java Virtual Machine (JVM) at runtime. On some JVMs, this might lead to an unnecessarily high memory consumption, especially when the memory for classes is restricted. This for example is the case for Perm Space in SUN JVMs.

To leverage this problem, the build of Web Dynpro applications has been enhanced with the Class File Minimizer, which enables the automatic analysis and reduction of generated code.

Caution

The Class File Minimizer is available for the Development Component Build (DC Build), as it requires information about public parts that is only available during the DC build. Therefore, the Class File Minimizer can only be used with Web Dynpro DCs.

 

The Class File Minimizer always analyzes a complete project, not parts of it. All class files that are part of a Web Dynpro DC are analyzed to detect and remove unused methods or fields.

Conceptually, the class path is separated into two parts: Firstly, a project part that contains the classes that are to be analyzed and reduced; secondly, an external part that contains all the classes referenced by the project classes: JDK, imported libraries, public parts of used DCs, and more. To keep the reduced code functional, the following code is always assumed to be called:

      Code in external class path

      Any implementation of external interfaces

      Methods that override methods of external base classes

      Classes that are part of a DC Public Part

      Constructors/methods that Web Dynpro calls via reflection (mainly constructors of controllers)

The Class File Minimizer iterates over all project classes, determines the entry points for each class from the above definition, and recursively visits any reached method or field. The information about all reached classes, fields, and methods is collected. When the iteration finally stops, there is a set of methods and fields that is not reachable in the sense of the above definition and can thus be safely removed.

More Information

Minimizing Byte Code

End of Content Area