Error compiling in IntelliJ IDEA: “No MessageCollector”

Promoting the answer in the comments to an answer, because it’s the actual answer: This appears to be a bug in the IntelliJ Kotlin plugin v1.2.40 and how it interacts with Java 10. See here. The solution is to upgrade to v1.2.41. (Don’t switch your project to building with Gradle like the other answer suggests … Read more

–add-modules only on compilation [duplicate]

I made this answer a while ago where I answered this as an additional info to exposing non java.se packages in Java-9 using Maven. The added part specifically focusses on using the standalone version of the java.xml.* APIs. To adapt to which you can probably start consuming the dependency on jaxb-api:2.3.0 which can be loaded … Read more

Replacing finalize() in Java

Java 9 introduces the Cleaner and Cleanable utility classes which take care of wiring up phantom references to a queue and a cleaning thread draining that queue. While this lets you separate out the witness that will perform a post-mortem cleanup after the owning object has died, all the caveats about GC-triggered resource management still … Read more

Package conflicts with automatic modules in Java 9

Am I using the new module system correctly? Yes. What you are seeing is intended behavior, and this is because JPMS modules do not allow split packages. In case you are not familiar with the term “split packages” it essentially means two members of the same package coming from two different modules. For example: com.foo.A … Read more

How to execute a java script with jshell?

Use //usr/bin/env jshell –show-version –execution local “$0” “$@”; exit $? as the first line of test.jsh. The test.jsh script could look like: //usr/bin/env jshell –show-version “$0” “$@”; exit $? System.out.println(“Hello World”) /exit The command line option –show-version is optional, of course, but gives immediate feedback that the tool is running. The extra command line option … Read more

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

Why is the finalize() method deprecated in Java 9?

Although the question was asking about the Object.finalize method, the subject really is about the finalization mechanism as a whole. This mechanism includes not only the surface API Object.finalize, but it also includes specifications of the programming language about the life cycle of objects, and practical impact on garbage collector implementations in JVMs. Much has … Read more

tech