I have this function throwing weird error when I try to do a "mvn install"
public <T> T get(final AN_ENUM key)
{
return some_map.get(key);
}
This is the line where I get the error
final int value = get(AN_ENUM.A_FIELD);
And this is the error in maven:
XXX.java:[25,41] type parameters of <T>T cannot be determined;
no unique maximal instance exists for type variable T with
upper bounds int,java.lang.Object
I know already how to "fix it". I just need to change the int
to Integer
in my last code sample and the bug goes away. It tell me that maven, for some sort of reason is not able to cast an Integer as an int when I use a type parameter.
My Question is.. why ?
In eclipse, using the same JDK, I have been able to run my application without any kind trouble nor warning.
In your pom.xml
, set the target version to at least 1.5:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
This way, Maven will use JDK 1.5 (or you can set it to 1.6 if you want).