I tried this with a clean checkout of master on a windows box (which I don’t 
normally do, but for this test…).

I’m not able to reproduce. My environment is slightly different in that I’m not 
using Eclipse, but rather building on Netbeans 8.2.

I am definitely using a 64 bit Java 8 (C:\Program Files\Java\jdk1.8.0_144).

 

Is it possible that you have an older JDK? IIRC, Eclipse Mars was a JDK 7 based 
build.

 

Brad

 

From: A Huarte via GeoTools-Devel [mailto:[email protected]] 
Sent: Tuesday, 26 December 2017 10:54 PM
To: Geotools-Devel List <[email protected]>
Subject: [Geotools-devel] GeoTools gt-metadata module does not build in 
master...

 

Hi, I am trying to build GeoTools and I get two errors in gt-metadata module.

I use Eclipse - Mars.1 Release (4.5.1) - in Windows.

 

 

...\modules\library\metadata\src\main\java\org\geotools\factory\CategoryRegistry.java

 

1) 

  public CategoryRegistry(final FactoryRegistry factoryRegistry,

            final Iterable<Class<?>> categories) {

        ...

        // use an unmodifiable map to guarantee immutability

        this.categories = stream(categories)

                .collect(

                        collectingAndThen(

                                toMap(category -> category,

                                      category -> new 
InstanceRegistry<>(factoryRegistry,category), <-- ERROR

                                      (firstRegistry, secondRegistry) -> 
secondRegistry),

                                      Collections::unmodifiableMap));

    }

 

ERROR --> Type mismatch: cannot convert from Object to 
Map<Class<?>,CategoryRegistry.InstanceRegistry<?>>

 

 

2) 

    public <S> Optional<S> getInstanceOfType(Class<S> type) {

        ...

        return streamCategories().filter(category -> 
category.isAssignableFrom(type))

                .map(this::instanceRegistry)                                    
                                          <-- ERROR

                .flatMap(registry -> 
stream(registry.getInstanceOfType(type))).findFirst();

    }

 

ERROR -> Type mismatch: cannot convert from Stream<Object> to <unknown>

 

 

 

 

I can fix these errors with a pair of minor changes:

 

1)

    public CategoryRegistry(final FactoryRegistry factoryRegistry,

            final Iterable<Class<?>> categories) {

        ...

        // use an unmodifiable map to guarantee immutability

        this.categories = stream(categories)

                .collect(

                        collectingAndThen(

                                toMap(category -> category,

                                      category -> new 
InstanceRegistry<Class<?>>(factoryRegistry,category),

                                      (firstRegistry, secondRegistry) -> 
secondRegistry),

                                      Collections::unmodifiableMap));

    }

 

2) 

    public <S> Optional<S> getInstanceOfType(Class<S> type) {

        ...

        return streamCategories().filter(category -> 
category.isAssignableFrom(type))

                .map(category -> (InstanceRegistry<?>) 
instanceRegistry(category))

                .flatMap(registry -> 
stream(registry.getInstanceOfType(type))).findFirst();

    }

 

 

But I do not know if they are right. Could you help me? Am I missing anything?

 

Thanks in advance

Alvaro

 

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
GeoTools-Devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-devel

Reply via email to