How to log request/response using java.net.http.HttpClient?

You can log request and responses by specifying-Djdk.httpclient.HttpClient.log=requests on the Java command line. As for testing/mocking you might want to have a look at the offline test: http://hg.openjdk.java.net/jdk/jdk/file/tip/test/jdk/java/net/httpclient/offline/ Depending on what you are looking to achieve you could use a “DelegatingHttpClient” to intercept and log requests and responses too. Besides the Java API documentation there’s … Read more

How to resolve module reads package error in java9

The problem is that your module path contains the same package (javax.annotation) in different modules (java.xml.ws.annotation and tomcat.embed.core), which the module system forbids in order to make configurations more reliable. This is called a split package. The module system tells you as much when listing all the modules that read (i.e. “see”) that package twice. … Read more

Does Project Lombok support Java 9?

The Lombok project has an issue tracking Java 9 support. As of January 9th 2018 and version 1.16.20, Lombok officially supports Java 9. From the changelog: PLATFORM: Better support for jdk9 in the new IntelliJ, Netbeans and for Gradle. BREAKING CHANGE: lombok config key lombok.addJavaxGeneratedAnnotation now defaults to false instead of true. Oracle broke this … Read more

JSR-305 annotations replacement for Java 9

It’s true that two modules cannot, ordinarily, define types in the same package. Until recently, putting jsr305.jar on the class path of a JDK 9 build would have no effect: That JAR file defines types in the javax.annotation package but that package is defined in the platform’s built-in java.xml.ws.annotation module, and the latter takes precedence. Owing … Read more

Correct way to use VarHandle in Java 9?

It is used for instance in AtomicReference, where previously in Java 8, sun.misc.Unsafe was used: public final void lazySet(V newValue) { unsafe.putOrderedObject(this, valueOffset, newValue); } public final boolean compareAndSet(V expect, V update) { return unsafe.compareAndSwapObject(this, valueOffset, expect, update); } Here the this pointer is used together with a field offset to access the field. But … Read more

What does “Required filename-based automodules detected.” warning mean?

Automatic module recap An explicit module (i.e. one with a module-info.java) can only access code of modules that it requires (ignoring implied readability for a moment). That’s great if all dependencies are modularized, but what if they are not? How to refer to a JAR that isn’t modular? Automatic modules are the answer: Any JAR … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)