Skip to content

List.of() or Collections.emptyList()

As an special case of List.of(…) or Collections.unmodifiableList() – what is the preferred Java 9 way of pointing to an empty and immutable list? Keep writing or switch to Answer What is the preferred Java 9 way of pointing to an empty and immutable list? The difference is rather subtle so “…

log4j2 double dollar $$ sign meaning in configuration

I am reading the configuration part of Log4j2. http://logging.apache.org/log4j/2.x/manual/configuration.html What is the meaning of double $$ sign? e.g. $${sd:type}? Answer It seems that $ is used as an escape character. As stated in Log4J documentation, Log4j configuration file parser uses Apache Commons Lan…

Understanding safe access of JNI arguments

I’m doing some research regarding how HotSpot performs garbage-collection and/or heap-compaction while JNI code is running. It appears to be common knowledge that objects could be moved at any time in Java. I’m trying to understand, definitively if JNI is subject to effects garbage-collection. The…

Xtend force java 7 language level

I am using Xtend in intellij from the Xtend-plugin. My project language level is set to Java 8 and Xtend compiles fine to Java 8 (e.g. using lambda expressions). For specific reasons, I need Xtend to generate Java 7 code, without changing the language level of my remaining project (Java 8). In the Xtend proje…

Get Values of variables under an Enum

I want to write into a file/print the constants of an enum, as well as the values of their variables. For example, here is what I thought of doing: However, I am not fully sure on how to do such a thing, as I only recently began working with reflection. This is the code that I currently have. Here is

JUnit – How many files for testing a single class?

Let’s say I have a class MyClass.java and we have to write a tests for it. Some of them will execute once, some of them will execute multiple times. I prepared two test classes – MyClassTestSingle.java for single tests and MyClassTestMultiple.java for tests with @Parametrized annotation. I wanted …