[ 
https://issues.apache.org/jira/browse/NETBEANS-789?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16474239#comment-16474239
 ] 

Eyso Zanstra commented on NETBEANS-789:
---------------------------------------

Using Java 8 as source code and target platform

> Omitting a generic type has a cascading effect; 
> ------------------------------------------------
>
>                 Key: NETBEANS-789
>                 URL: https://issues.apache.org/jira/browse/NETBEANS-789
>             Project: NetBeans
>          Issue Type: Bug
>    Affects Versions: 8.2
>         Environment: Windows 8.1 64 bit
> Processor Intel i7-4720HQ @2.60Ghz
> 16GB RAM
>            Reporter: Eyso Zanstra
>            Priority: Major
>
> Example code:
>  
> {code:java}
> package util;
> import java.util.Collection;
> import java.util.HashSet;
> import java.util.Set;
> import java.util.Optional;
> /**
>  *
>  * @author eyso
>  * @param <T> example generic
>  */
> public class Foo<T> {
>     private final T val;
>     private Optional<Long> timestamp = Optional.<Long>empty();
>     public Foo(T val) {
>         this.val = val;
>         timestamp = Optional.of(System.currentTimeMillis());
>     }
>     public Optional<Long> getTimestamp() {
>         return timestamp;
>     }
>     public static Set<Long> getTimestamps(Collection<Foo> foos) {
>         Set<Long> result = new HashSet<Long>();
>         for (Foo foo : foos) {
>             if (foo.getTimestamp().isPresent()) {
>                 result.add(foo.getTimestamp().get()); //Argument mismatch;
>             }
>         }
>         return result;
>     }
> }
> {code}
> This raises an error: Argument mismatch; Object cannot be converted to Long



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@netbeans.apache.org
For additional commands, e-mail: commits-h...@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to