JAXB not available on Tomcat 9 and Java 9/10

Analysis First some random facts: if not given a class loader, JAXBContext::newInstance will use the thread’s context class loader when looking for the JAXB implementation – this is the case even if you call newInstance(Class…) (one might mistakenly think it uses the provided class instances’ loader) Tomcat builds a small class loader hierarchy to separate … Read more

Explanation of the Thread-Local Handshakes

After researching JEP: 312 Thread-Local-Handshakes and reading the excellent comments to this question, here is a quick summary. It is a performance enhancement which cannot be used directly by developers: A handshake mechanism is proposed as an optimisation of the Hotspot safepoints mechanism. The former allows threads in a safepoint to continue executing immediately after … Read more

Generics behavior differs in JDK 8 and 9

After some research I believe we can rule this out as a Junit or hamcrest issue. Indeed, this seems to be a JDK bug. The following code will not compile in JDK > 8: AnyOf<Iterable<? super String>> matcher = CoreMatchers.anyOf( CoreMatchers.hasItem(“d”), CoreMatchers.hasItem(“e”), CoreMatchers.hasItem(“f”)); Error:(23, 63) java: incompatible types: inference variable T has incompatible bounds equality … Read more

How to uninstall JDK on Mac OS?

From the official Oracle manual. Navigate to /Library/Java/JavaVirtualMachines and remove the directory whose name matches the following format: /Library/Java/JavaVirtualMachines/jdkmajor.minor.macro[_update].jdk For example, to uninstall 8u6: %rm -rf jdk1.8.0_06.jdk Do not attempt to uninstall Java by removing the Java tools from /usr/bin. This directory is part of the system software and any changes will be reset by … Read more

Java 10: Will Java 7’s Diamond Inference Work with Local Type Inference?

Yes, var and the diamond operator can be combined together. The compiler will infer the most specific generic type: var list = new ArrayList<>(); // Infers ArrayList<Object> var list = new ArrayList<>(List.of(1, 2, 3)); // Infers ArrayList<Integer> And you can even combine them with an anonymous class: var list = new ArrayList<>() {};

findResource(“”) returning null when module-info.java is present, why is that?

One thing I notice is that your application (assuming that it’s packaged in tech.flexpoint.dashman) does not seem to be opened up to Spring in any way, which will surely result in failed class loading/illegal access. I would expect to see something like this in module-info.java (depending on your Spring dependencies): opens tech.flexpoint.dashman to spring.core, spring.beans, … Read more

SimpleDateFormat with German Locale – Java 8 vs Java 10+

I don’t say it’s a nice solution, but it seems to be a way through. Map<Long, String> dayOfWeekTexts = Map.of(1L, “Mo”, 2L, “Di”, 3L, “Mi”, 4L, “Do”, 5L, “Fr”, 6L, “Sa”, 7L, “So”); Map<Long, String> monthTexts = Map.ofEntries(Map.entry(1L, “Jan”), Map.entry(2L, “Feb”), Map.entry(3L, “Mär”), Map.entry(4L, “Apr”), Map.entry(5L, “Mai”), Map.entry(6L, “Jun”), Map.entry(7L, “Jul”), Map.entry(8L, “Aug”), Map.entry(9L, “Sep”), … Read more

Proper fix for Java 10 complaining about illegal reflection access by jaxb-impl 2.3.0?

jaxb-ri runtime uses ClassLoader#defineClass / Unsafe#defineClass to do some bytecode modification in runtime to optimize performance. ClassLoader#defineClass is tried first which causes the warning. This legacy optimization is removed completely in jaxb-ri master (after 2.3.0, not released yet). To disable this optimization for 2.3.0, set system property com.sun.xml.bind.v2.bytecode.ClassTailor.noOptimize. After next jaxb-ri release updating to newest … Read more