You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@directory.apache.org by Stefan Seelmann <se...@apache.org> on 2007/11/18 21:48:57 UTC
[Studio] Build problem with List cast
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
Re: [Studio] Build problem with List cast
Posted by Emmanuel Lecharny <el...@gmail.com>.
Stefan Seelmann wrote:
> Hi Dev,
>
> in Studio we have the following line of code:
>
> configuration.setSupportedMechanisms( new ArrayList<String>( ( List<?
> extends String> )
I think this is not allowed, because String can't be extended.
--
--
cordialement, regards,
Emmanuel Lécharny
www.iktek.com
directory.apache.org
Re: [Studio] Build problem with List cast
Posted by David Jencks <da...@yahoo.com>.
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
Re: [Studio] Build problem with List cast
Posted by Pierre-Arnaud Marcelot <pa...@marcelot.net>.
Hi Stefan,
On Nov 18, 2007 9:48 PM, Stefan Seelmann <se...@apache.org> wrote:
> The odd thing is if I just touch the java file (adding a space
> somewhere) the compilation works!
You're right... It does the same here on my machine...
I don't understand either what's happening... That's very very odd...
Regards,
Pierre-Arnaud Marcelot