score:1
summary:
- your code is invalid.
- oxygen's java compiler incorrectly allows your code to compile.
- photon's java compiler correctly reports an error with your code.
concat()
will return a stream of a type which is the closest match for the types of the streams being concatenated. for example, if you concat()
a stream<int>
with a stream<long>
then concat()
will return a stream<number>
.
and if you concat()
two streams whose elements bear no relationship with each other, such as stream<string>
and stream<long>
, then concat()
will return a stream<object>
. that is what happens in your code, since myclass
and myinterface
bear no relationship to each other, apart from having object
as a parent.
it looks like something was implicitly casting the return type of filter to stream which then lead to stream.concat returning the expected type.
that explanation looks tempting since it appears to fit the facts, but what happens if the predicate in your filter is changed to test for runnable
instead of myinterface
?
stream<myinterface> concatenation2 = stream.concat(
myclassstream.filter(element -> element instanceof runnable),
myinterfacestream);
the code still compiles and the tooltip is unchanged, so the filtering is clearly not impacting the return type. put another way, the first parameter to concat()
will return a stream<myclass>
regardless of what is done in filter()
. the fact that your filter guaranteed that it would also only return myinterface
elements is not relevant, but it appeared to be significant because the type of the variable receiving the stream from concat()
was stream<myinterface>
.
and what happens if the type of the variable receiving the stream from concat()
is changed from myinterface
to something absurd and meaningless such as deque<localdatetime>
?...
stream<deque<localdatetime>> concatenation3 = stream.concat(
myclassstream.filter(element -> element instanceof myinterface),
myinterfacestream);
two things are notable:
- even though that code is obviously invalid, it still compiles on oxygen (but not on photon).
- the tooltip for
concat()
now shows its return type to bestream<deque<localdatetime>>
which clearly makes no sense.
why did this code break? how could i get previous behavior?
oxygen's compiler was allowing invalid variable definitions using stream.concat()
, and it seems that this was fixed in photon. you shouldn't want that previous behavior since it was incorrect.
Source: stackoverflow.com
Related Query
- Eclipse IDE Java implicit casting
- Eclipse java IDE - method undefined quick fix only proposing casting
- Eclipse IDE for Java - Full Dark Theme
- Eclipse IDE - Error: Build path specifies execution environment Java SE 1.7
- Did anyone create the Java Code Formatter Profile for Eclipse IDE that conforms to the Android Code Style Rules?
- Catching exceptions as an expression while debugging Java in Eclipse IDE
- Kotlin And Java In The Same Project Using Eclipse IDE
- Java Eclipse IDE - Repository Errors
- Eclipse IDE for C/C++ and Java
- I don't have "Database Development Perspective" in Eclipse Java SE IDE
- Java How to beautify the java code inside Eclipse IDE
- Automatically generate Java from .proto with maven/m2e in Eclipse IDE
- Is it possible to use sysout without class and main method in Eclipse IDE using Java 9?
- Ant Build Error in Eclipse IDE for Java
- Difference between Eclipse IDE for Java EE Developers and Eclipse Juno
- Eclipse Standard or Eclipse IDE for Java Developers?
- Setting the classpath in java using Eclipse IDE
- How to set up other-than-eclipse Java compiler for Eclipse IDE
- How to use Robot Framework with Java using Eclipse as IDE
- Installation of FindBugs plugin with Eclipse IDE for Java EE Developers
- Eclipse Java EE IDE not supporting javax.servlet package
- Eclipse Web Tools Platform (WTP) vs NetBeans - IDE for Java Web Development
- why "yyy" word in java comment in eclipse ide take a special style?
- Can I develop android applications using Eclipse IDE for Java EE?
- Is there a reason to have both Eclipse IDE for Java and also Eclipse IDE for Java EE?
- Eclipse Java IDE JUnit5: junit.jupiter.api.Assertions is not accessible
- Convert Java stream to regular for loop expression in Eclipse IDE
- Scala IDE not working properly in Eclipse Luna for Java EE
- Java - Eclipse IDE
- Unable to establish database connection to SQL Server 2008 using java in Eclipse IDE
More Query from same tag
- Taking in Webdriver element name as a parameter
- Eclipse : Element type "Context" must be declared
- Create Random Number with 16 Digits (JAVA)
- Android "Error generating final archive: Failed to add .../bin/resources.ap_"
- How do you make Eclipse not edit all the occurrences found by "Find Next"?
- Removing @WebServlet causes java.lang.ClassNotFoundException
- How to open Eclipse editor programatically without passing an IFile object
- What is different in different user accounts when doing a maven build
- Unable to execute Maven project from command line through java command
- could not resolve module
- Eclipse Juno not working/opening
- Git hub project _ Learning)
- GDB Exits/Crashes while Trying to Debug TensorFlow C++ Code
- Eclipse RCPTT Hanging in Jenkins
- I am not getting any error but nothing is getting inserted into my database
- eclipse debugging keys not working
- ASTVisitor in Eclipse
- How to set a static variable in every class?
- How can I generate an Android Keystore from a key.pk8 and certificate.pem?
- Change the executable name in Eclipse for C++
- Eclipse: Compiling A Plugin For Java 1.5: "Columns For Eclipse"
- Displaying a variable from an ArrayList of objects in a JScrollPane
- Replacing a method with only particular types of parameter in Eclipse
- Thread-Safe way to access EclipsePreferences (Project)
- I forget to stop a gui program and run it again. Now I can't close the first program without killing eclipse
- How do I configure Eclipse web browser/network settings?
- PMD-Plugin in Eclipse/Juno not installable through marketplace
- Android emulator screen
- Android - Signed apk not running
- Can a perfect circle encompassing face be formed using euler angle in face detector