Bug #263

Datatype 16-bit enumeration cannot be held in a Byte

Added by Philipp Buluschek almost 4 years ago. Updated almost 4 years ago.

Status:Closed Start date:10/09/2014
Priority:Normal Due date:
Assignee:Stefano Lenzi % Done:


Category:zigbee.zcl.library Spent time: -
Target version:org.aaloa.zb4osgi.zigbee.zcl.library-0.9.0
Has a patch:No Has license agreement signed:No


In ZigBeeType.java

Enumeration16bit(0x31, 2, false, Byte.class),

should be

Enumeration16bit(0x31, 2, false, Integer.class),

as Byte cannot hold 16 bits.

Associated revisions

Revision 1075
Added by Stefano Lenzi almost 4 years ago

Using always Intger for signed inter data
Enumration16bit now has enough space for storing the value ( refs #263 )


#1 Updated by Stefano Lenzi almost 4 years ago

  • Category set to zigbee.zcl.library
  • Status changed from New to Resolved
  • Assignee set to Stefano Lenzi
  • Target version set to org.aaloa.zb4osgi.zigbee.zcl.library-0.9.0

Fixed the issue, pleas close it if you agree on it.

#2 Updated by Philipp Buluschek almost 4 years ago

In the change you also adapted Enumeration8bit to use Integer - why?
I agree that it really makes no difference (the value is always requested with Number.byteValue), but it would be most logical to use the smallest Java data type able to hold the corresponding ZigBee data type...

#3 Updated by Stefano Lenzi almost 4 years ago

Yes we may decide to use the smallest Java size for storing the data, but considering that we are using Object (Integer, Short, and so on) it is easier to upcast everything to Integer (when it fits) or Long (when it is needed).
It will avoid casting issues and it would not wast so much memory, considering that Object requires 8 bytes for overhead of JVM plus the actual content for storing the data Byte = 1, Short = 2, Integer = 4, and Long = 8; but due to 8-byte alignment all the above types require 16 bytes of momery (As far as I know)

See http://stackoverflow.com/questions/258120/what-is-the-memory-consumption-of-an-object-in-java

So if you agree we can close the issue.

#4 Updated by Philipp Buluschek almost 4 years ago

  • Status changed from Resolved to Closed

OK for me.

Also available in: Atom PDF