Error message

A quick note. I just spent 10 frustrating minutes trying to figure out the following error message:

C:\ ... java:20: type parameters of <U>U cannot be determined; no unique maximal instance exists for type variable U with upper bounds java.lang.String,java.util.Collection<java.lang.String>

public String getPatternNames() { return CollectionManager.copyInto(patternNames, ArrayList.class); }

^

1 error

Tool completed with exit code 1

The source code was the following:

private List<String> patternNames;

public String getPatternNames(){return CollectionManager.copyInto(patternNames, ArrayList.class);}

This error message was so confusing that I didn't notice the immediately obvious:

publicString getPatternNames()

should have been

publicList<String> getPatternNames()

Changing the return type to the above fixed the error immediately.

However, it seems that javac throws this weird compilation error rather than the more sensible

C:\ ... java:20: incompatible types

found: java.util.List<java.lang.String>

required: java.lang.String

1 error

that it perhaps should have, simply because it was dealing with a generic method (CollectionManager.copyInto( ) which is generic).

Just a heads up (is this a bug btw?)

[1585 byte] By [fragorla] at [2007-10-2 12:01:53]
# 1
D*mmit, why did it change the title to "Error Message"? That's not what I called this thread!
fragorla at 2007-7-13 8:18:51 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...