Get declared fields of java.lang.reflect.Fields in jdk12

Why It No Longer Works The reason this no longer works in Java 12 is due to JDK-8210522. This CSR says: Summary Core reflection has a filtering mechanism to hide security and integrity sensitive fields and methods from Class getXXXField(s) and getXXXMethod(s). The filtering mechanism has been used for several releases to hide security sensitive … Read more

Compile and execute a JDK preview feature with Maven

Step 1 One can make use of the following maven configurations to compile the code using the –enable-preview along with –release 12+ (e.g. 13, 14, 15) argument. <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.8.0</version> <configuration> <release>12</release> <!– <release>13/14/15</release> –> <compilerArgs>–enable-preview</compilerArgs> </configuration> </plugin> <!– This is just to make sure the class is set as main class … Read more

The package org.w3c.dom is accessible from more than one module: , java.xml

I had a similar issue because of a transitive xml-apis dependency. I resolved it using a Maven exclusion: <dependency> <groupId>org.apache.xmlgraphics</groupId> <artifactId>fop</artifactId> <version>0.95</version> <exclusions> <exclusion> <groupId>xml-apis</groupId> <artifactId>xml-apis</artifactId> </exclusion> </exclusions> </dependency> Another dependency that just causes trouble and I don’t have a solution other than removing it is this one: <dependency> <groupId>com.oracle.database.xml</groupId> <artifactId>xmlparserv2</artifactId> <version>${oracle.version}</version> </dependency> Use mvn … Read more

Mystifying microbenchmark result for stream API on Java 12 vs. Java 8 with -gc true

Thanks, everyone for the help and especially to @Aleksey Shipilev! After applied changes to JMH benchmark, the results look more realistic (?) Changes: Change the setup method to be executed before/after each iteration of the benchmark. @Setup(Level.Invocation) -> @Setup(Level.Iteration) Stop JMH forcing GC between iterations. Forcing Full GC before each iteration is quite likely to … Read more