Mikalai Zaikin wrote:
I am glad you use our sample quiz for Java learning.
If you are using IntelliJ Idea (even free Community edition) you can use advanced debugger feature to check how pipeline processes data.
Hope screenshots explain it.
2024-02-19 21:20:30,661 [ 196382] INFO - #c.i.c.s.BuildManager - BUILDER_PROCESS [stderr]: Be careful, logger will be shut down earlier than application: Unable to make field private static java.util.IdentityHashMap java.lang.ApplicationShutdownHooks.hooks accessible: module java.base does not "opens java.lang" to unnamed module @2f4d3709
2024-02-19 21:20:30,690 [ 196411] INFO - #c.i.c.s.BuildManager - BUILDER_PROCESS [stdout]: Build process started. Classpath: C:/Program Files/JetBrains/IntelliJ IDEA Community Edition 2022.2.3/plugins/java/lib/jps-launcher.jar
2024-02-19 21:20:30,707 [ 196428] INFO - #c.i.a.d.c.d.t.TimeSpanUserActivityDatabaseThrottler - Starting activity runconfig.running with id 2064515432
2024-02-19 21:20:37,835 [ 203556] WARN - org.apache.velocity.deprecation - configuration key 'resource.loader' has been deprecated in favor of 'resource.loaders'
2024-02-19 21:20:37,837 [ 203558] WARN - org.apache.velocity.deprecation - configuration key 'includes.resource.loader.class' has been deprecated in favor of 'resource.loader.includes.class'
2024-02-19 21:20:38,365 [ 204086] INFO - #c.i.r.e.ExtractLightMethodObjectHandler - Use reflection to evaluate inaccessible members
2024-02-19 21:20:38,838 [ 204559] INFO - #c.i.r.e.ExtractGeneratedClassUtil - Replace constructor: GeneratedEvaluationClass
2024-02-19 21:20:38,839 [ 204560] INFO - #c.i.r.e.ExtractGeneratedClassUtil - Replace method: invoke
2024-02-19 21:20:38,839 [ 204560] INFO - #c.i.r.e.ExtractGeneratedClassUtil - Replace method: myRes
2024-02-19 21:20:38,840 [ 204561] INFO - #c.i.r.e.ExtractGeneratedClassUtil - Replace method: result
2024-02-19 21:20:41,319 [ 207040] SEVERE - #c.i.d.i.InvokeThread - Internal error
com.intellij.debugger.streams.diagnostic.ex.TraceCompilationException: Internal error
at com.intellij.debugger.streams.action.TraceStreamAction$1.compilationFailed(TraceStreamAction.java:133)
at com.intellij.debugger.streams.trace.EvaluateExpressionTracer$1.errorOccurred(EvaluateExpressionTracer.java:86)
at com.intellij.debugger.engine.JavaDebuggerEvaluator$1.threadAction(JavaDebuggerEvaluator.java:96)
at com.intellij.debugger.engine.events.DebuggerContextCommandImpl.contextAction(DebuggerContextCommandImpl.java:72)
at com.intellij.debugger.engine.events.SuspendContextCommandImpl.action(SuspendContextCommandImpl.java:48)
at com.intellij.debugger.engine.events.DebuggerCommandImpl.run(DebuggerCommandImpl.java:40)
at com.intellij.debugger.engine.DebuggerManagerThreadImpl.processEvent(DebuggerManagerThreadImpl.java:155)
at com.intellij.debugger.engine.DebuggerManagerThreadImpl.processEvent(DebuggerManagerThreadImpl.java:27)
at com.intellij.debugger.impl.InvokeThread.lambda$run$0(InvokeThread.java:140)
at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$1(CoreProgressManager.java:192)
at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$executeProcessUnderProgress$12(CoreProgressManager.java:610)
at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:685)
at com.intellij.openapi.progress.impl.CoreProgressManager.computeUnderProgress(CoreProgressManager.java:641)
at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:609)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:78)
at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:179)
at com.intellij.debugger.impl.InvokeThread.lambda$run$1(InvokeThread.java:126)
at com.intellij.openapi.project.DumbService.runWithAlternativeResolveEnabled(DumbService.kt:331)
at com.intellij.debugger.impl.InvokeThread.run(InvokeThread.java:126)
at com.intellij.debugger.impl.InvokeThread$WorkerThreadRequest.lambda$run$0(InvokeThread.java:49)
at com.intellij.util.ConcurrencyUtil.runUnderThreadName(ConcurrencyUtil.java:218)
at com.intellij.debugger.impl.InvokeThread$WorkerThreadRequest.run(InvokeThread.java:48)
at com.intellij.openapi.application.impl.ApplicationImpl$2.run(ApplicationImpl.java:249)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
at com.intellij.util.concurrency.ContextCallable.call(ContextCallable.java:32)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at com.intellij.util.concurrency.ContextRunnable.run(ContextRunnable.java:27)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:702)
at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:699)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1.run(Executors.java:699)
at java.base/java.lang.Thread.run(Thread.java:840)
Experience keeps a dear School, but Fools will learn in no other.
---
Benjamin Franklin - Postal official and Weather observer
Tim Holloway wrote:Seems like peek should be able to do it,
Ron McLeod wrote:You should be able to peek into a Map and Map.Entry.
Anil Philip wrote:peek() is not supported on all data structures. For instance on maps, that are in this pipeline, peek will not work.
In cases where the stream implementation is able to optimize away the production of some or all the elements (such as with short-circuiting operations like findFirst, or in the example described in count()), the action will not be invoked for those elements.
Anil Philip wrote:It is actually dangerous in my humble opinion, to have complex pipelines because bugs will never get detected nor fixed - because the code is hard to understand.
Experience keeps a dear School, but Fools will learn in no other.
---
Benjamin Franklin - Postal official and Weather observer
Mike Simmons wrote:Thanks! I hadn't really considered it; in fact I just came up with most of it. But perhaps it's worth doing something like that...
Anil Philip wrote:
Mike Simmons wrote:Thanks! I hadn't really considered it; in fact I just came up with most of it. But perhaps it's worth doing something like that...
Honestly, I did not understand - it all went over my head. I am not very intelligent.
Anil Philip wrote:
Mike Simmons wrote:Thanks! I hadn't really considered it; in fact I just came up with most of it. But perhaps it's worth doing something like that...
Honestly, I did not understand - it all went over my head. I am not very intelligent.
But I am convinced this is a shortcoming of Java.
I am thinking of playing with the Streams API, modifying the implementing code just to experiment and try out an idea.
Is it very hard to understand how-to, and modify and build the JDK on my local machine? Has anyone outside of Oracle done it?
Experience keeps a dear School, but Fools will learn in no other.
---
Benjamin Franklin - Postal official and Weather observer
Tim Holloway wrote:
I wouldn't recommend building your own JDK just to understand streams. ...
but anyone can "git clone" the OpenJDK source and build it. Like many open-source projects, it's just a matter of cloning or downloading/unzipping, running the "configure" to get it to detect your OS environment and build makefiles, then "make" to build it. Mostly it just takes a while to do all that compiling and such, since it's a large system.
Build instructions wrote:
At a minimum, a machine with 2-4 cores is advisable, as well as 2-4 GB of RAM. (The more cores to use, the more memory you need.) At least 6 GB of free disk space is required.
Experience keeps a dear School, but Fools will learn in no other.
---
Benjamin Franklin - Postal official and Weather observer
Tim Holloway wrote:The build instructions in the source archive are pretty detailed and they say you can build in 6GB of disk space, but it's disk-intensive so the faster the disk, the better, e.g., SSD.
Have fun, and tell us how it went!