graph icon indicating copy to clipboard operation
graph copied to clipboard

Incompatible types: Map<Object,Object> cannot be converted to Map<String,?>

Open sposhraj opened this issue 5 years ago • 1 comments

Sir,

While executing the below java programs I faced compilation error and thought it would be right to let you know the problems I encountered, post verification it can be refactored as stated below.

TinkerGraphTest.java RemoteClient.java

Below code tested with java8
1] TinkerGraphTest.java
Line 52:
    Map<String,?> aus = g.V().has("code","AUS").valueMap().next();
Error on compilation: TinkerGraphTest.java:52: error: incompatible types: Map<Object,Object> cannot be converted to Map<String,?>
Rectification:
    New versions of java will throw error and could be rectified as below
    Map<Object,Object> aus = g.V().has("code","AUS").valueMap().next();
2] RemoteClient.java
Line 34 and 38:
    List <Map<String,Object>> vmaps =
    for (Map <String,Object> m : vmaps)
Error on compilation: RemoteClient.java:35: error: incompatible types: List<Map<Object,Object>> cannot be converted to List<Map<String,Object>>
Rectification:
    Same as above one.
    List <Map<Object,Object>> vmaps =
    for (Map <Object,Object> m : vmaps)

I personally have not executed JanusCassandra.java other java programs, but similar issue might arise there too and where above like statements are used.

Regards, Poshraj Sharma

sposhraj avatar May 23 '20 18:05 sposhraj

Thanks for reporting these - a while back the valueMap return type changed. Please let me know if you find any others @sposhraj

krlawrence avatar Mar 21 '21 19:03 krlawrence

Closing as this is fixed and work has now started on the second edition. There will likely be one final release of the v283 first edition line before the V2 branch becomes the second edition. That release will include these fixes.

krlawrence avatar Sep 23 '23 18:09 krlawrence