Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: normativized, JPCERT comment integration

The only unsigned primitive integer type in Java is the 16 bit char data type; all of the other primitive integer types are signed. To interoperate with native languages, such as C or C++, that use unsigned types extensively, read any unsigned values must be read and stored into the next larger Java signed primitive integer a Java integer type that can represent all of the values of the signed type. For example, use a the Java long type to hold an unsigned 32-bit integer value obtained from native code.

...

This noncompliant code example uses a generic method for reading in integer data without considering the signedness of the source. It assumes that the values read are always signed and treats the most significant bit as the sign bit. When the data being read is unsigned, this causes misinterpretations of the actual sign and magnitude of the value.

...

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="450b6276f2969cd1-9db0179e-459a4da0-98d9a153-55f4a28aec3e916faa39e2e5"><ac:plain-text-body><![CDATA[

[[API 2006

AA. Bibliography#API 06]]

Class DataInputStream: method readInt

]]></ac:plain-text-body></ac:structured-macro>

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="3c7accb100afa418-16547d3c-44cd4af8-b716ab4b-8532da73d551bd78a530c2cd"><ac:plain-text-body><![CDATA[

[[Harold 1997

AA. Bibliography#Harold 97]]

Chapter 2: Primitive Data Types, Cross Platform Issues, Unsigned Integers

]]></ac:plain-text-body></ac:structured-macro>

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="444ae3f26ee797a8-8f96f496-4e3f4679-8154a461-ecfbb196fe214e1694e1c820"><ac:plain-text-body><![CDATA[

[[Hitchens 2002

AA. Bibliography#Hitchens 02]]

2.4.5 Accessing Unsigned Data

]]></ac:plain-text-body></ac:structured-macro>

...