Compilation optimization


#1

Hi,

I would like to know if the unused java code is remove from the binary at the compilation time: If there is any code which is not called in my main or any of my threads, will it present in the final binary (microejapp.o) ?

Thanks


#2

Hi Thomas,

Yes MicroEJ SOAR will only keep:

  • Directly used Java code: e.g. new MyObject().myFunction() => Will embed MyObject constructor and its hierarrchy, myFunction and all the subfunctions used by it.
  • Code that might be used by polymorphism: for instance if you override myFunction on MyChild inheriting of MyObject, even if you don’t call myFunction on MyChild, it will be embedded as well because it might be called at runtime.
  • Code explicitly embedded when you add a type to a types.list file, all the class will be embedded, it is useful when you want to to instantiate a class in a reflexive way (with a forName).

Regards,