Skip to content

Tag: java

Logging JSON-RPC calls using jsonrpc4j

I’m sure that if you have used jsonrpc4j (outside a spring container) you will recognise the following standard pattern. I am trying to create a log file containing all the JSON requests and JSON responses. i.e. I’d like to log the incoming JSON RPC request before it is deserialised and log the ou…

Java “”(” expected” compiler error

I’m a beginner in Java and after a few time of studying this language by books, I decided to write a simple program that “encrypts” a string by replacing numbers with letters and vice versa. It is not finished yet and has some considerable restrictions, but it should work as is. The code: It…

Java 8: Lambda with variable arguments

I am looking for a way to invoke multiple argument methods but using a lambda construct. In the documentation it is said that lambda is only usable if it can map to a functional interface. I want to do something like: Is there any way one can do this elegantly without defining 10 interfaces, one for each argu…

Java 8 stream short-circuit

Reading up a bit on Java 8, I got to this blog post explaining a bit about streams and reduction of them, and when it would be possible to short-circuit the reduction. At the bottom it states: Note in the case of findFirst or findAny we only need the first value which matches the predicate (although findAny i…

Speed of custom Java classes vs. Maps

Which is faster: a Set whose elements are each an instance of CustomObject as defined below: a Set whose elements are each an instance of Map<String, String> where each Map is of the format {“A” : Avalue, “B” : Bvalue, “C” : Cvalue}? or any other data structure that y…

How do I trigger the default signal handling behavior?

In my Java application I want to capture SIGINTs, do some pre-processing, and then let the default behavior (process termination) run. I would think I could do something like this: However when I send at SIGINT to this application, I get a SEGV: It seems SignalHandler.SIG_DFL is not meant to be called directl…