directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Jencks <david_jen...@yahoo.com>
Subject Re: [Studio] Build problem with List cast
Date Sun, 18 Nov 2007 22:02:51 GMT
If supportedMechanismsTableViewer.getCheckedElements() returns String 
[] then I'd expect

new ArrayList<String>(Arrays.asList 
(supportedMechanismsTableViewer.getCheckedElements()))

to work.

If it returns something else such as Object[] you might try

new ArrayList<String>(Arrays.<String>asList 
(supportedMechanismsTableViewer.getCheckedElements()))

to give Arrays.asList a hint as to what you want.

Hope this helps
david jencks

On Nov 18, 2007, at 3:48 PM, Stefan Seelmann wrote:

> Hi Dev,
>
> in Studio we have the following line of code:
>
> configuration.setSupportedMechanisms( new ArrayList<String>( ( List<?
> extends String> ) Arrays.asList(
> supportedMechanismsTableViewer.getCheckedElements() ) ) );
>
> The method configuration.setSupportedMechanisms expects an  
> List<String>
> parameter. The "supportedMechanismsTableViewer.getCheckedElements()"
> returns an Object[].
>
> Inside of eclipse this line is just marked with a warning: "Type  
> safety:
> Unchecked cast from List<Object> to List<? extends String>"
>
>
> But when building from command line using ant I get the following  
> error:
>
>     [javac]
> /home/stefan/Documents/Apache/svn/studio/trunk2/studio-apacheds- 
> configuration/src/main/java/org/apache/directory/studio/apacheds/ 
> configuration/editor/GeneralPage.java:878:
> inconvertible types
>     [javac] found   : java.util.List<java.lang.Object>
>     [javac] required: java.util.List<? extends java.lang.String>
>     [javac]             .asList(
> supportedMechanismsTableViewer.getCheckedElements() ) ) );
>
>
> The odd thing is if I just touch the java file (adding a space
> somewhere) the compilation works!
>
>
> Any idea what may be the problem here?
>
>
> Here is the class:
> http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds- 
> configuration/src/main/java/org/apache/directory/studio/apacheds/ 
> configuration/editor/GeneralPage.java?view=markup&pathrev=596110
>
> Regards,
> Stefan


Mime
View raw message