% Demonstrate that
%	- there is a cache for dynamically discovered Java methods and
%    the cache is re-initialized if the class of the target object or
%    the number or class of arguments change dynamically.

:- eval(ex005()).

ex005() :-
	println(["==========ex005=========="]),

	ID=1,
	Map1=java.util.HashMap(),
	Map1.put(ID,"1"),
	run(Map1,ID),
	% HashMap.get() will use the cached discovered method 
	run(Map1,ID),

	Map2=java.util.Hashtable(),
	Map2.put(ID,"2"),
	% Hashtable.get() will re-initialize the cache because the target class
	%    has changed.
	run(Map2,ID),
	% And now again from the cache
	run(Map2,ID).

run(Map,ID) :-
	Data=Map.get(ID),
	println(["Data=",Data]).
