From: Mark Rotteveel <mark@lawinegevaar.nl>
To: pgsql-jdbc@lists.postgresql.org
Subject: Re: getTypeMap() returns null - bug?
Date: Tue, 12 May 2020 14:42:57 +0200
Message-ID: <dbb7c04e4128e3bb7502dad19aeadf93@lawinegevaar.nl> (raw)
In-Reply-To: <c242e29538102940cdf6f398a6666dd7ff033e83.camel@gmail.com>
References: <af26d6b5-6f61-7e21-4972-2c719357bef6.ref@yahoo.com>
<af26d6b5-6f61-7e21-4972-2c719357bef6@yahoo.com>
<e6a8e0de373300df2d42211a1fc1d94b7693ad02.camel@gmail.com>
<f44eec01-dce5-7a29-388b-a3994d29e1df@yahoo.com>
<c242e29538102940cdf6f398a6666dd7ff033e83.camel@gmail.com>
On 2020-05-12 06:10, rob stone wrote:
> On Mon, 2020-05-11 at 02:28 -0400, javadesigner wrote:
>> empty is not the same as null in java. this is a java specific
>> discussion btw.
>>
>
> Vraimente.
>
> java.util.Map map = con.getTypeMap();
>
> So, the variable "map" is now an empty map object. Highly likely it
> contains hex zeroes. It could contain the string "empty" but that does
> not sound reasonable. Maybe there is no memory address and memory is
> only allocated with the first "put".
That is not how maps work in Java. A map is a collection of keys and
values (aka a hashtable or dictionary), an empty map has no keys (and
thus no values).
> System.out.println("map:"+map);
>
> So, println accesses the memory occupied by the object and assuming it
> contains unprintable hex zeroes, it can either display "null", or
> convert to printable zeroes or ignore it and display nothing.
>
> What output did you expect from "System.out.println("map:"+map);"??
> That is the question.
Printing out a map is not what you'd normally do in Java, but if you do,
an empty map will print (without quotes): '{}', assuming the
java.util.HashMap implementation or the value of
java.util.Collections.emptyMap().
Mark
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-jdbc@postgresql.org
Cc: mark@lawinegevaar.nl
Subject: Re: getTypeMap() returns null - bug?
In-Reply-To: <dbb7c04e4128e3bb7502dad19aeadf93@lawinegevaar.nl>
References: <af26d6b5-6f61-7e21-4972-2c719357bef6.ref@yahoo.com> <af26d6b5-6f61-7e21-4972-2c719357bef6@yahoo.com> <e6a8e0de373300df2d42211a1fc1d94b7693ad02.camel@gmail.com> <f44eec01-dce5-7a29-388b-a3994d29e1df@yahoo.com> <c242e29538102940cdf6f398a6666dd7ff033e83.camel@gmail.com> <dbb7c04e4128e3bb7502dad19aeadf93@lawinegevaar.nl>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox