Skip to content
Advertisement

Tag: java-8

Logging from default interface methods

Salut to all Java gurus! Since Java8 we can have default implementations in interfaces (yay!). However problem arises when you want to log from default method. I have a feeling that it is not wise to call .getLogger() every time I want to log something in a default method. Yes, one can define static variable in an interface – but

JDK8 – Error “class file for javax.interceptor.InterceptorBinding not found” when trying to generate javadoc using Maven javadoc plugin

I am using JDK8 (tried it on my Eclipse workspace with Win x64 u25 JDK + on Linux launched by Jenkins – jdk-8u20-linux-x64, same problem for both). I have multi-module Maven project (I am launching Maven goal “javadoc:aggregate” from a main module with packaging type “pom”). Pom build section looks like this: I always receive error: I have tried everything

Java access bean methods with LambdaMetafactory

my question is strongly related to Explicit use of LambdaMetafactory in that thread, some very good examples are provided to use the LambdaMetafactory to access a static method of a class; however, I wonder what is the equivalent code to access a non static field of an existing bean instance. It seems really hard to find an example and every

Unit testing a class with a Java 8 Clock

Java 8 introduced java.time.Clock which can be used as an argument to many other java.time objects, allowing you to inject a real or fake clock into them. For example, I know you can create a Clock.fixed() and then call Instant.now(clock) and it will return the fixed Instant you provided. This sounds perfect for unit testing! However, I’m having trouble figuring

What’s the difference between map() and flatMap() methods in Java 8?

In Java 8, what’s the difference between Stream.map() and Stream.flatMap() methods? Answer Both map and flatMap can be applied to a Stream<T> and they both return a Stream<R>. The difference is that the map operation produces one output value for each input value, whereas the flatMap operation produces an arbitrary number (zero or more) values for each input value. This

Advertisement