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

Andy Seaborne edited comment on JENA-667 at 4/2/14 10:19 AM:
-------------------------------------------------------------

In Java 1.8, there is, on the {{Map}} interface as new default method:
{noformat}
    default boolean remove(Object key, Object value) {
{noformat}
which removes the entry iff the key is associated with the value.

Reading the {{Map}} javadoc, I think the operation is sufficiently close to the 
intent of the new default method, to mean that the patch is the right way to 
proceed. The alternative is to rename as {{removeOne}}.  The {{get(Object)}} 
contract on {{OneToMany}} means the code isn't being completely exact anyway. 
The {{Map}} default implementation uses {{get(Object)}} to test for presence in 
the multimap.

It does cause a compiler warning for lack of @Override when using JDK 1.8.



was (Author: andy.seaborne):
In Java 1.8, there is, on the {{Map}} interface as new default method:
{noformat}
    default boolean remove(Object key, Object value) {
{noformat}
which removes the entry iff the key is associated with the value.

Reading the {{Map}} javadoc, I think the operation is sufficiently close to the 
intent of the new default method, to mean that the patch is the right way to 
proceed. The alternative is to rename as {{removeOne}}.  The {{get(Object)}} 
contract on {{OneToMany}} means the code isn't being completely exact anyway.

It does cause a compiler warning for lack of @Override when using JDK 1.8.


> Build breaks when compiling with JDK 1.8 - Modified Map Implemententation
> -------------------------------------------------------------------------
>
>                 Key: JENA-667
>                 URL: https://issues.apache.org/jira/browse/JENA-667
>             Project: Apache Jena
>          Issue Type: Improvement
>          Components: Build
>    Affects Versions: Jena 2.11.1, Jena 2.11.2
>         Environment: java version "1.8.0"
> Java(TM) SE Runtime Environment (build 1.8.0-b132)
> Java HotSpot(TM) 64-Bit Server VM (build 25.0-b70, mixed mode)
>            Reporter: Christoph Emmersberger
>            Assignee: Andy Seaborne
>         Attachments: JENA-667.patch
>
>
> When running the build with JDK 1.8 (Java 8), the following compilation error 
> occurs:
> {code}
> public class OneToManyMap<From, To> implements Map<From, To> {
>     ...
>     public void remove( Object key, Object value ) {
>         List<To> entries = m_table.get( key );
>         if (entries != null) {
>             entries.remove( value );
>             
>             if (entries.isEmpty()) {
>                 m_table.remove( key );
>             }
>         }
>     }
>     ...
> }
> {code}
> Seems like the underlying Map implementation has been modified to provide a 
> boolean return statement as of JDK 1.8
> {code}
>     public boolean remove(Object key, Object value) { 
>         ...
>     }
> {code}



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to