How can a close() method invoked from Stream point to the implementation of the close() method in the AbstractPipeline abstract class?

stack overflow
:

I just started learning Java Streams, and I have a question. Something that confuses me a lot is the following:

  1. I just checked out the AutoCloseable interface and it holds the close() method.

  2. The BaseStream interface extends the AutoCloseable interface, and the rule of inheritance supplies, meaning that the close() method can be used from the BaseStream interface.

  3. The Stream interface extends the BaseStream interface, and the rule of inheritance supplies, meaning that the close() method can be used from the Stream interface.

  4. Also, the abstract class AbstractPipeline implements the BaseStream interface and it provides an implementation of the close() method.

This is the diagram of the previously described.

List<String> stringList = new ArrayList<>();
Stream<String> stringStream = stringList.stream();
stringStream.close();

When I hold the Ctrl keyboard button and click left click on the mouse it points me to the abstraction of the close() method in the BaseStream interface, but when I press Ctrl+Alt+B it points me to the implementation of the method in the AbstractPipeline abstract class.

The question is:

How can a close() method that is invoked of Stream point me to the implementation of the close() method in the AbstractPipeline abstract class, when Stream and AbstractPipeline do not interact and their main connection is the BaseStream?

Is this some kind of object oriented concept that i'm not aware of?

Thank you.

Update:

I'm using IntelliJ IDEA 2020.1.2 (Ultimate edition) and JDK 1.8 but I've also tried it with JDK 14 and Eclipse IDE for Enterprise Java Developers version 2019-06 (4.12.0) and it is the same.

stack overflow
:

There is an abstract class ReferencePipeline which extends abstract class AbstractPipeline and implements Stream, but isn't overriding the close() method. This abstract class is the connection and the answer I was looking for. Now, everything seams reasonable and is clear for me. Here is the full diagram, which clears the answer to this question.

enter image description here

Thanks to everyone that participated and helped me find the answer. Cheers!

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How can I prevent from a close method being invoked?

From Dev

How to close stream before return in method?

From Dev

Optional method implementation in an abstract class

From Dev

partial implementation of abstract method of an abstract class

From Dev

When running a method from a Python superclass, how can I know the name of the child class that invoked it?

From Dev

When running a method from a Python superclass, how can I know the name of the child class that invoked it?

From Dev

How to enforce method execution from abstract class?

From Dev

Java Stream close method ambiguous behaviour

From Dev

How does one write a method for an abstract class that returns the type of the implementation?

From Dev

How does one write a method for an abstract class that returns the type of the implementation?

From Dev

How can I close a primefaces panel through JavaScript method?

From Dev

How can I execute a method when I force close an application

From Dev

Method inheritance from abstract class

From Dev

How to close a HttpWebResponse being returned from a method call

From Dev

how getview method of baseadapter class invoked

From Dev

How to call a method in an abstract class

From Dev

how can i implement specific method from two different abstract class?

From Dev

How to refer to an abstract class' method inside a method

From Dev

Prevent abstract implementation from overriding certain method

From Dev

How can I access injected Grails beans in an abstract class method?

From Dev

How can we identify if a method belongs to an abstract class or an interface?

From Dev

How can we use the abstract getScreenSize() method in Toolkit class?

From Dev

Partial implementation of an abstract method?

From Dev

Native implementation of an abstract method

From Dev

Partial implementation of an abstract method?

From Dev

Abstract method implementation (if unused)

From Dev

How to mock protected subclass method inherited from abstract class?

From Dev

How to Access method from a sub- abstract class

From Dev

How to mock inherited protected method from abstract class

Related Related

  1. 1

    How can I prevent from a close method being invoked?

  2. 2

    How to close stream before return in method?

  3. 3

    Optional method implementation in an abstract class

  4. 4

    partial implementation of abstract method of an abstract class

  5. 5

    When running a method from a Python superclass, how can I know the name of the child class that invoked it?

  6. 6

    When running a method from a Python superclass, how can I know the name of the child class that invoked it?

  7. 7

    How to enforce method execution from abstract class?

  8. 8

    Java Stream close method ambiguous behaviour

  9. 9

    How does one write a method for an abstract class that returns the type of the implementation?

  10. 10

    How does one write a method for an abstract class that returns the type of the implementation?

  11. 11

    How can I close a primefaces panel through JavaScript method?

  12. 12

    How can I execute a method when I force close an application

  13. 13

    Method inheritance from abstract class

  14. 14

    How to close a HttpWebResponse being returned from a method call

  15. 15

    how getview method of baseadapter class invoked

  16. 16

    How to call a method in an abstract class

  17. 17

    how can i implement specific method from two different abstract class?

  18. 18

    How to refer to an abstract class' method inside a method

  19. 19

    Prevent abstract implementation from overriding certain method

  20. 20

    How can I access injected Grails beans in an abstract class method?

  21. 21

    How can we identify if a method belongs to an abstract class or an interface?

  22. 22

    How can we use the abstract getScreenSize() method in Toolkit class?

  23. 23

    Partial implementation of an abstract method?

  24. 24

    Native implementation of an abstract method

  25. 25

    Partial implementation of an abstract method?

  26. 26

    Abstract method implementation (if unused)

  27. 27

    How to mock protected subclass method inherited from abstract class?

  28. 28

    How to Access method from a sub- abstract class

  29. 29

    How to mock inherited protected method from abstract class

HotTag

Archive