Home > Products > SophiaCompress(Java) OASIS > Inside SophiaCpmpress(Java) > - 8 -

Inside SophiaCompress(Java) OASIS

Class integration

class

Class Integration is a technique to minimize the number of classes. More items in the same CP or class file will be shared; fewer classes equates to smaller program size.

SophiaCompress(Java) OASIS implements this technique by iterating the integration of two classes as many times possible.

The following three criteria are considered when determining if two classes may be integrated.

  1. parent classes
  2. method override
  3. logic

1. parent class

Either of the following requirements must be satisfied.

  1. The parent of either class is java.lang.Object. (i.e. no parent classes)
  2. Both of the two classes have the same parent.
  3. Either of two classes is a parent of the other.

2. method override

These two classes that both have a method with the same signature but different implementations, cannot be integrated. (The signature is the combination of method name and its parameters).

3. logic

If a Class or its child class is contained in instanceof predicates, its semantics may be changed after being integrated with other classes; therefore class integration may not be used.

As for two classes that can be integrated, they are integrated basically by copying methods or fields from one to another.

Each field of the integrated class will never contain a value, which is simultaneously valid for both the original classes. Even after integration, its instances behave only as instances of either of the original classes.

That is to say that fields of the same type may be shared after Class Integration.