Tag Archives

Archive of posts published in the tag: Java

Erasure type inference issue in Java

Recently I was working with the following code:

I was compiling it with

on Windows 10 x64. It wasn’t working because of the following:

You can try reproducing the issue at compilejava.net, it throws the error at the moment. I…

JVM Inside Out Part 4 — Locks and out of band exceptions

This is the fourth part of the JVM Inside Out series. For your convenience you can find other parts in the table of contents in Part 1 — Getting object address Typical locking pattern in Java (and other languages, even outside them JVM…

JVM Inside Out Part 3 — Java raw type trickery

This is the third part of the JVM Inside Out series. For your convenience you can find other parts in the table of contents in Part 1 — Getting object address Erasure in Java seems pretty easy but sometimes it has unexpected consequences.…

Comparing numbers is hard

We know that to compare floating point values we should use epsilon and not just compare bits. We may run into similar issues when comparing BigDecimal in Java:

What is the output? Of course it is false, otherwise I wouldn’t write this…

Spark and NegativeArraySizeException

Recently I was debugging the following crash in Spark:

Disabling Kryo solves the issue. To do that just set spark.serializer to org.apache.spark.serializer.JavaSerializer. Other workaround is to change Kryo’s reference management, as explained on Github:

Spark and NullPointerException in UTF8String.contains

Recently I was debugging a NullPointerException in Spark. The stacktrace was indicating this:

After some digging I found out that the following query causes the problem:

If I commented out the line with the comment the NPE was no longer there.…

Playing With args4j Part 5 — Safe setters

This is the fifth part of the Playing With args4j series. For your convenience you can find other parts in the table of contents in Part 1 – Mixins There is one more problem with our setters — they are not type safe.…

Playing With args4j Part 4 — Nicer setters

This is the fourth part of the Playing With args4j series. For your convenience you can find other parts in the table of contents in Part 1 – Mixins Last time we ended with the setter of a form

. What we don’t…

Playing With args4j Part 3 — Nice setters

This is the third part of the Playing With args4j series. For your convenience you can find other parts in the table of contents in Part 1 – Mixins Let’s see how we can implement the setters. Idea is as following: we will…

Playing With args4j Part 2 — Automatic getters

This is the second part of the Playing With args4j series. For your convenience you can find other parts in the table of contents in Part 1 – Mixins Last time we created mixins to be able to compose classes with multiple inherited…

Playing With args4j Part 1 — Mixins

This is the first part of the Playing With args4j series. For your convenience you can find other parts using the links below (or by guessing the address): Part 1 — Mixins Part 2 — Automatic getters Part 3 — Nice setters Part…

Source compatibility issue with Google Guava library

Recently I was debugging a case of NoSuchMethodError when using the Google Guava library. Conceptually my code was doing the following:

In runtime I was using library in version 19 and I was getting the following error:

I decompiled the code…

Random notes from crashing and hanging EMR Spark job

It sometimes happens that your EMR job crashes or hangs indefinitely with no meaningful log. You can try to capture memory dump but it is not very useful when your cluster machines have hundreds gigabytes of memory each. Below are “fixes” which worked…

Investigating AWS SDK conflicts in EMR

When you deploy your package to Amazon Elastic Map Reduce (EMR), you can access the AWS SDK provided by the platform. This gets tricky if you compile your code against different version of SDK because then you may get very cryptic bugs in…

Trivial ScheduledThreadPoolExecutor in C#

Today we are going to implement trivial ScheduledExecutorService in C#. Introduction We want to have a thread pool of fixed size which we can use to execute three types of tasks: One time tasks Tasks with fixed delay between executions Tasks with fixed…

Dynamically loading JAR file in Zeppelin

Imagine that you need to load JAR file dynamically in Zeppelin working on your EMR cluster. One easy way is to deploy the file to the instance and load it from there, however, what can you do if you have almost no access…

Generating class in Zeppelin

If you want to declare a class in Zeppelin and create instance of it, you might be surprised:

What happened? Whatever you declare in Zeppelin notebook is a part of some internal class so the newly declared class K…

Concurrency Part 3 – Java mutex via JNI

This is the third part of the Concurrency series. For your convenience you can find other parts in the table of contents in Part 1 – Mutex performance in .NET Last time we saw file lock in Java which we can use on…

Concurrency Part 2 – Java file lock

This is the second part of the Concurrency series. For your convenience you can find other parts in the table of contents in Part 1 – Mutex performance in .NET Today we explore system-wide lock in Java 1.8.0_161 on Windows 10 x64. There…

DLL Injection Part 7 — Injecting Java code

This is the seventh part of the DLL Injection series. For your convenience you can find other parts in the table of contents in Part 1 – Registry We already injected native code into target, managed code into default application domain, and managed…