wocommunity / wolips

wolips
53 stars 53 forks source link

Fix compilation failure on woproject-ant-tasks #138

Closed hprange closed 6 years ago

hprange commented 6 years ago

While trying to release a new version of woproject-ant-tasks, I faced compilation failures on multiple classes. All of them caused by a reference to WOEnvironment is ambiguous error. E.g.:

[ERROR] .../org/objectstyle/woproject/ant/WOApplication.java:[556,21] reference to WOEnvironment is ambiguous
[ERROR]   both constructor WOEnvironment(java.util.Map<java.lang.Object,java.lang.Object>) in org.objectstyle.woenvironment.env.WOEnvironment 
    and constructor WOEnvironment(java.util.Hashtable<java.lang.String,java.lang.Object>) in org.objectstyle.woenvironment.env.WOEnvironment match

Java is unable to choose between Map<Object, Object> and Hashtable<String, Object> when you pass a raw Hashtable as a parameter. Oh, the joy of Java Generics. It always confuses me. :)

I was digging into the Git history when I found out that the WOEnvironment constructor receiving a Hashtable<String, Object> parameter was introduced to solve, guess what, a compilation failure. As pointed out by Pascal Robert in this comment, a Hashtable<String, Object> couldn't be converted to Map<Object, Object> using Ant version 1.9.3.

This pull request makes the constructors of WOEnvironment and WOVariables classes more flexible by replacing the parameterized type Map<Object, Object> with the unbounded wildcard type Map<?, ?>; hence, supporting old and new versions of Ant without errors.

I've also updated the Ant dependency version to 1.10.3 when building woproject-ant-tasks with Maven.

You can find more information about the original change on this pull request, more specifically, on this commit.

hprange commented 6 years ago

@fbarthez I can cut a new release of the woproject-ant-tasks project as soon as we merge this change into master. Can you check if it works for you?

fbarthez commented 6 years ago

@hprange Sorry this is taking me so long! I'll only be able to look at it on Wednesday…

fbarthez commented 6 years ago

Works for me – sorry it took me so long!