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.
I had a similar issue and it turns out that I was attempting to return a "boolean"(Primitive) and not a "Boolean"(Object). Since you're trying to set it to an "int"(primitive) it will end up failing.
Try changing your "int" to an "Integer" and hopefully that should fix it.
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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With