Bug 545304 - AspectJ Maven Plugin Type Mismatch on Collector after implementing Interface in Stream
Summary: AspectJ Maven Plugin Type Mismatch on Collector after implementing Interface ...
Status: NEW
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: 1.9.2   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: aspectj inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-03-12 09:39 EDT by Gonçalo Garcia CLA
Modified: 2019-03-12 09:39 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Gonçalo Garcia CLA 2019-03-12 09:39:36 EDT
I'm trying to compile the following code with ajc through the Maven compiler plugin:


~~ Main.java ~~

public class Main {

    public static void main(String[] args) {
        List<DataStore> list = new LinkedList<>();
        list.add(null);
        list.add(null);
        list.add(null);
        list.add(null);
        list.add(null);


        List<DataStore> integersPlusOne = list.stream().map(store -> new DataStore() {
            @Override
            public void connect() {

            }

            @Override
            public void disconnect() {

            }

            @Override
            public void write(UUID value) {

            }

            @Override
            public List<String> read(String value) {
                return null;
            }
        }).collect(Collectors.toList());
    }
}

But it does not compile with the following error message: Type mismatch: cannot convert from List<Object> to List<DataStore>

It compiles fine when I run it through javac.

Here is the DataStore class, and my POM.

~~ DataStore.java ~~

public interface DataStore {


    public void connect();

    public void disconnect();

    public void write(UUID value);

    public List<String> read(String value);


}


~~~ pom.xml ~~~

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>minimal-aspectj</groupId>
    <artifactId>minimal</artifactId>
    <version>1.0-SNAPSHOT</version>

    <properties>
        <maven.compiler.target>1.8</maven.compiler.target>
        <maven.compiler.source>1.8</maven.compiler.source>
    </properties>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>8</source>
                    <target>8</target>
                </configuration>
            </plugin>
        </plugins>
    </build>
    <profiles>
        <profile>
            <id>aspectj</id>
            <activation>
                <property>
                    <name>aspectj</name>
                </property>
            </activation>
            <dependencies>
                <dependency>
                    <groupId>org.aspectj</groupId>
                    <artifactId>aspectjrt</artifactId>
                    <version>1.9.3.RC1</version>
                </dependency>
            </dependencies>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>aspectj-maven-plugin</artifactId>
                        <version>1.11</version>
                        <configuration>
                            <complianceLevel>1.8</complianceLevel>
                            <source>1.8</source>
                            <target>1.8</target>
                            <showWeaveInfo>true</showWeaveInfo>
                            <verbose>true</verbose>
                            <Xlint>ignore</Xlint>
                            <encoding>UTF-8 </encoding>
                            <weaveDependencies>
                            </weaveDependencies>
                        </configuration>
                        <executions>
                            <execution>
                                <id>compile</id>
                                <goals>
                                    <goal>compile</goal>
                                    <goal>test-compile</goal>
                                </goals>
                                <phase>compile</phase>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

</project>