guptasuresh2004 / osgi-in-action

Automatically exported from code.google.com/p/osgi-in-action
Apache License 2.0
0 stars 0 forks source link

implementation dependent code #2

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Just look at the line 86 of ShapeTracker class in chapter 3 example
code. That is:

if ((m_context.getBundle(0).getState() & (Bundle.STARTING | Bundle.ACTIVE))
== 0)

2.
3.

What is the expected output? What do you see instead?
This code would only work if the different states in the Bundle interface
are set as a bit-map i.e. if a single bit is set to represent the state.
This might be a plausible expectation but by no means it is guaranteed
since the data type of the states defined in the Bundle interface is simply
an "int". This becomes more interesting because the book suggests that one
of the goals in OSGi modularity layer is to hide the implementation details
from the client code. 

What version of the product are you using? On what operating system?

I believe I am using  osgi-in-action-20090928.zip

Please provide any additional information below.

Original issue reported on code.google.com by sanjari....@gmail.com on 8 Oct 2009 at 6:10

GoogleCodeExporter commented 9 years ago
The OSGi specification (section 6.1.4) explicitly defines the states in the 
Bundle as
a bitmask, so it is perfectly acceptable to query them this way. The JVM
specification contains similar definitions, such as:

  http://java.sun.com/javase/6/docs/api/java/lang/reflect/Modifier.html
  http://java.sun.com/docs/books/jvms/second_edition/html/ClassFile.doc.html#75734

This doesn't stop you from abstracting Bundle states behind your own API if you 
wish.

Original comment by mccu...@gmail.com on 9 Oct 2009 at 10:16