Post by Dhilipan ManoharanThe containsKey method when running in java7 returns false for a string key and it returns true when its running in java6 for a string key eligibly present in the map.
What implementation of the JVM are you using?
Presumably the string pooling in the JVM implementation is the same,
but that's one thing to check.
Perhaps the trouble is the performance bug in JDK7 due to the new hashing
algorithm?
You didn't use -Djdk.map.althashing.threshold
and -XX:UseGetTimeOfDay,
correct?
Looking at the openjdk 7 source code, you can see the instance variable 'useAltHashing' in HashMap.
useAltHashing = sun.misc.VM.isBooted() &&
(capacity >= Holder.ALTERNATIVE_HASHING_THRESHOLD);
-Nichole
---In ***@yahoogroups.com, <doug-***@...> wrote:
Dhilipan - can you post some code that demonstrates what exactly you're seeing?
A bit like my sample code earlier in the thread.
It'll help us a lot in figuring out what is going on.
Doug
On Wed, Nov 20, 2013 at 7:09 PM, Dhilipan Manoharan <***@... mailto:***@...> wrote:
hi all,
To be more precise, containsKey fails for these values consistenly on a cloned map (5,10) but not for others.
Please guide me.
Thanks,
Dhilipan M
From: Nimret Sandhu <***@... mailto:***@...>
To: "***@yahoogroups.com mailto:***@yahoogroups.com" <***@yahoogroups.com mailto:***@yahoogroups.com>
Sent: Wednesday, 20 November 2013 2:10 PM
Subject: Re: [seajug] hashmap in java7
whups .. throw new RuntimeApiMisunderstoodException() .. thx for the correction :)
cheers,
-
Nimret Sandhu
http://www.nimret.org/ http://www.nimret.org/
On Wed, Nov 20, 2013 at 11:13 AM, Konstantin Ignatyev <***@... mailto:***@...> wrote:
What do you mean Nimret? Not cloning keys and values does _not_ mean they are not present in the cloned map, only that they are the same objects as in original map.
So keyExists should succeed on the cloned map provided that key has consistent hash and properly implements hashCode and equals methods.
On Wed, Nov 20, 2013 at 10:59 AM, Nimret Sandhu <***@... mailto:***@...> wrote:
works as advertised :)
http://docs.oracle.com/javase/7/docs/api/java/util/HashMap.html#clone() http://docs.oracle.com/javase/7/docs/api/java/util/HashMap.html#clone()
per the docs clone() does a shallow copy - it does not copy over the keys/values.
see http://goo.gl/zaGPmM http://goo.gl/zaGPmM for a deep copy/clone
cheers,
-
Nimret Sandhu
http://www.nimret.org/ http://www.nimret.org/
On Wed, Nov 20, 2013 at 10:04 AM, Dhilipan Manoharan <***@... mailto:***@...> wrote:
Here is what i found when i digged further.
after cloning a hashmap i am not able to find the key using containsKey method in j7.
I removed the clone and it finds the key.
Thanks,
Dhilipan M
From: Dhilipan Manoharan <***@... mailto:***@...>
To: "***@yahoogroups.com mailto:***@yahoogroups.com" <***@yahoogroups.com mailto:***@yahoogroups.com>
Sent: Tuesday, 19 November 2013 3:57 PM
Subject: Re: [seajug] hashmap in java7
I dont have any unit test case,but am running my application in two different machines having java6 and java7 and i noticed this behaviour.
Thanks,
Dhilipan M
From: Eric Jain <***@... mailto:***@...>
To: seajug <***@yahoogroups.com mailto:***@yahoogroups.com>
Sent: Tuesday, 19 November 2013 3:02 PM
Subject: Re: [seajug] hashmap in java7
Post by Dhilipan ManoharanThe containsKey method when running in java7 returns false for a string key and it returns true when its running in java6 for a string key eligibly present in the map.
Do you have a unit test that demonstrates this behavior?
--
Eric Jain
zenobase.com http://zenobase.com/ -- What do you want to track today?
--
Konstantin Ignatyev
PS: If this is a typical day on planet Earth, humans will add fifteen million tons of carbon to the atmosphere, destroy 115 square miles of tropical rainforest, create seventy-two miles of desert, eliminate between forty to one hundred species, erode seventy-one million tons of topsoil, add 2,700 tons of CFCs to the stratosphere, and increase their population by 263,000
Bowers, C.A. The Culture of Denial: Why the Environmental Movement Needs a Strategy for Reforming Universities and Public Schools. New York: State University of New York Press, 1997: (4) (5) (p.206)