Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8108977
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T01:16:35+00:00 2026-06-06T01:16:35+00:00

I know that the specification exactly defines it but cannot get what is the

  • 0

I know that the specification exactly defines it but cannot get what is the reason for this:

A class space is then all classes reachable from a given bundle’s class loader. 
Thus, a class space for a given bundle can contain classes from:
• The parent class loader (normally java.* packages from the boot class path)
• Imported packages
• Required  bundles
• The bundle's class path (private packages)
• Attached fragments

Let’s assume:

  1. A bundle declares “import-package: a”
  2. There is a local class a.X in this bundle
  3. There is a class a.X in another bundle

new a.X() would load the class from another bundle.

What is the reason that imported classes take precedence over bundle classes? Is it just a consequent continuation of java hierarchical class loading policy?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T01:16:36+00:00Added an answer on June 6, 2026 at 1:16 am

    This is actually a core aspect of OSGi.

    Sharing classes

    The whole import/export mechanism is intended to let different bundles use the same class when communicating. Same in this case means not only binary equal, but loaded by the same class loader (recall that every bundle has its own class loader). If the bundle’s own classes would be favored over imported ones, bundles would not be able to ‘agree’ on which copy of a class to use.

    But… why?

    Why would you have a copy of a class, which you also intend to import?
    Consider a situation in which you want to do some logging, so you import org.osgi.service.log, but it’s not a vital aspect, you can happily run without a LogService present. Now,

    • if you would only import the package, your bundle would fail to resolve, and thus fail to start, and
    • if you would only include the class, you would never use the other bundle’s LogService class, so you cannot use the service (this is the agreeing part).

    In this situation, you both import and include the class, so you can run in either situation, using your own copy when no one else has one, and sharing a copy if someone else does. You can even choose to export your copy, and let the framework decide.

    As a sidenote, this is exactly the reason you should (almost) always import what you export.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know that this question has been asked previously, but before you give me
I know that this line of code will make the cell text-wrap: $objPHPExcel->getActiveSheet()->getStyle('D1')->getAlignment()->setWrapText(true); 'D1'
I know that Java have its own garbage collection, but sometimes I want to
I know that the ECMA Script specification does not specify which algorithm to use
I don't know if this is compiler specific but when I tried running the
Does anyone know of a JavaScript library that accurately implements the IEEE 754 specification
We all know that deadlines and/or critical bugfixes and make us forget a bit
From the JCR specification I know that I can request an UserTransaction object (specified
I know that automatic properties must define a get and set accessor method, I
I know that I can hijack a form by showing a login form in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.