Detecting missing and unnecessarily imported packages in OSGi bundles

When developing OSGi based application in Eclipse adding required import package declaration is assisted by PDE. In practice, it means that import package declarations are never missing – otherwise Eclipse project won’t comile and run. What programmers almost never do is to remove unnecessary declarations. Why would they if it works? In practice bundle manifests polluted with unnecessary imported packages can cause performance issues during bundle resolution and classloading and sometimes confuse Eclipse PDE during development.

To mitigate this problem I’ve created a small application leveraging the power of excellent BND library. I was really surprised when I run this tool against bundles from application I’m currently working on – some had literally hundreds of unnecessarily imported packages.

oipv 1.x
Usage: oipv [options]

  -j <jar1>,<jar2>... | --jars <jar1>,<jar2>...
        jars or folders to include
  -e <package1>,<package2> | --exclude-package <package1>,<package2>
        Package prefixes to exclude from analysis. You may want to
        excluded packages exported by JRE - javax.swing, javax.sql, etc.
        to avoid false positives
  --help
        print usage text

Application code available at GitHub (github.com) – https://github.com/jarek-przygodzki/osgi-import-package-verifier. The app itself is available here: oipv-1.0-master-f6c5c79.zip

Skomentuj

Wprowadź swoje dane lub kliknij jedną z tych ikon, aby się zalogować:

Logo WordPress.com

Komentujesz korzystając z konta WordPress.com. Log Out / Zmień )

Zdjęcie z Twittera

Komentujesz korzystając z konta Twitter. Log Out / Zmień )

Facebook photo

Komentujesz korzystając z konta Facebook. Log Out / Zmień )

Google+ photo

Komentujesz korzystając z konta Google+. Log Out / Zmień )

Connecting to %s