Community
Participate
Working Groups
Eclipse compiler on JDK 11 project and compiler setting does work in a Prdicate, e.g. filter on list: list.stream() .filter(s -> s.length() == 1) .forEach(System.out::println); However, it does not work in a unary operator Function, e.g. map on list: list.stream() .map((var s) -> s.toLowerCase()) .forEach(System.out::println); This results in 2 Java Problems: - The method map(Function<? super String,? extends R>) in the type Stream<String> is not applicable for the arguments ((var s) -> {}) - The method toLowerCase() is undefined for the type ? super String The same class compiled directly with javac works fine for both cases.
Sorry, forgot "var" in case 1 with filter if I add it like that list.stream() .filter((var s) -> s.length() == 1) .forEach(System.out::println); it does not work either and shows also 2 Problems: - The method filter(Predicate<? super String>) in the type Stream<String> is not applicable for the arguments ((var s) -> {}) - The method length() is undefined for the type ? super String So error is not limited to unary operator Function, but also in Predicate.
Eclipse 4.9 does not support Java 11 (incl. JEP 323). Do you have Support for Java 11 installed? One of: - https://marketplace.eclipse.org/content/java-11-support-eclipse-2018-09-49 - using a recent milestone or I-build of Eclipse Otherwise this would be a duplicate of bug 531711.
Yes, I installed the current version of the Java 11 support from marketplace. IDE is 20180917-1800 and I already did a check for updates and installed JDT update, but didn't change the error behaviour. Also, a fresh download, both EE and SE edition of IDE with current Java 11 support plugin does not solve it. Then I downloaded the current OpenJDK 11 version - still no change. So from what I can see, JEP 323 might work partly with your sample in help section of plugin, so it accepts the lambda usage syntax, but does not for this correct statement, which compiles fine with pure javac or Maven build: list.stream() .map((var s) -> s.toLowerCase()) .forEach(System.out::println);
Created attachment 276687 [details] Demo maven project demonstrating error
I also tried the current IDE milestone M2 of 4.10 (Build 20181108-1653). It is also not able to compile the mentioned command. Find attached a simple demo maven project which builds fine with mvn clean install and a JAVA_HOME set to OpenJDK 11. The same project imported in recent Eclipse IDE with Java 11 support does not.
I am also experiencing this issue. Any chance this is getting looked at soon? Still an issue with the R4_10_maintenance branch (built commit tagged with R4_10).
I can reproduce the problem from comment 0 in today's HEAD. Definitely there's no reason that a program should become invalid just by inserting 'var'. @Manoj, via bug 534787 you introduced argumentsTypeVar() which in my understanding should produce mostly the same semantics as argumentsTypeElided(). However, the latter is called from 17 locations, whereas the former only from 1. Couldn't we treat both cases the same way, by letting argumentsTypeElided() answer true also for 'var'? What difference does 'var' make for compilation?
(In reply to Stephan Herrmann from comment #7) > I can reproduce the problem from comment 0 in today's HEAD. > > Definitely there's no reason that a program should become invalid just by > inserting 'var'. > > @Manoj, via bug 534787 you introduced argumentsTypeVar() which in my > understanding should produce mostly the same semantics as > argumentsTypeElided(). However, the latter is called from 17 locations, > whereas the former only from 1. > > Couldn't we treat both cases the same way, by letting argumentsTypeElided() > answer true also for 'var'? What difference does 'var' make for compilation? @Stephan: Thanks for finding the root cause of the issue. Yes, I agree that var should be treated at par/identical with argumentsTypeElided - will submit a patch in that effect.
New Gerrit change created: https://git.eclipse.org/r/135596
Gerrit change https://git.eclipse.org/r/135596 was merged to [master]. Commit: http://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/?id=4c49f905582020b5bbace350773b0eba3dc92fb8
(In reply to Eclipse Genie from comment #10) > Gerrit change https://git.eclipse.org/r/135596 was merged to [master]. > Commit: > http://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/ > ?id=4c49f905582020b5bbace350773b0eba3dc92fb8 I have confirmed that this commit resolves my issues. Thanks!
(In reply to Ryan Ulch from comment #11) > > I have confirmed that this commit resolves my issues. Thanks! Thanks Ryan for the confirmation - I am moving this to resolved.
The test introduced here triggered failure in RUN_JAVAC mode[1]. I'm fixing this via bug 543856. [1] https://ci.eclipse.org/jdt/job/eclipse.jdt.core-run.javac-11/15/testReport/org.eclipse.jdt.core.tests.compiler.regression/JEP323VarLambdaParamsTest/testBug541532_01___11/
*** Bug 544217 has been marked as a duplicate of this bug. ***
verified for 4.11 M3 using build I20190219-1800.
*** Bug 545542 has been marked as a duplicate of this bug. ***