Skip to content
Advertisement

Tag: java-9

Java9 modules : How to execute Provider based on some priority of execution?

I am using java 9 modules to implement provider , i have multiple providers for service interface. I want to provide some priority for providers for their execution insted of using findFirst(); I have service-interface modules as below , ServiceInterface.Java module-info.java I have provider-module which has two implementation for service interface , Provider1.java Provider2.java module-info.java Now , i have consumer-module

Stream groupBy to nested maps with casting

Need to calculate total number by gender from below structure of nested Maps. But as data stored as Object need to cast it at every iteration. After grouping not able to cast last leaf Map to calculate and filter date object. Applied below stream, Answer It is a rather unusual way to store data. I would recommend you to implement

Is try-with-resource not safe when declaring multiple effectively final resources?

Since Java 9 we can use effectively final variables in try-with-resources. The example below presents a situation where one of the resources initialization throws an exception. When I run this example, the only output I get is a RuntimeException, meaning that Resource1 was not closed. That was expected, since it wasn’t initialized in the try-with-resources. But, is this the expected

how to pass –add-opens JDK module configuration to maven test

I’m upgrading java version in our production code from java 8 to java 11. I have to add the below JDK module configuration in the application java start command due to usage of third party libraries like flume, zookeeper etc. –add-opens java.base/java.lang=ALL-UNNAMED –add-opens jdk.management/com.sun.management.internal=ALL-UNNAMED After adding this configuration and java application is starting fine. But when I run the tests

gradle Jigsaw module not found

I try to run a very simple gradle project which uses java 9 modules, but i receive the following error. Here is it https://github.com/vad0/test_modules. The main class does basically nothing. It uses only one dependency: HdrHistogram. I included this magic command in build.gradle according to official gradle tutorial https://docs.gradle.org/current/samples/sample_java_modules_multi_project.html. The whole build.gradle looks like this. module.info looks like this I

How does ServiceLoader.load work with class loaders in JPMS?

I have two JPMS layers: Boot layer with module A loaded by ClassLoaders$AppClassLoader@4fca772d Child layer with module B that provides cervices and loaded by Loader@6b58b9e9 The parent classloader of Loader@6b58b9e9 is ClassLoaders$AppClassLoader@4fca772d. In module A I have the following code: However, the services of Module B are found only when context class loader is Loader@6b58b9e9 and not found when context

Functional style java.util.regex match/group extraction

Using java.util.regex to extract substrings I find myself implementing the same code pattern working around calls to : Is there a functional extension or popular library (guava / apache commons) that avoids the ugly unnecessary and error-prone local variable, like: and also a stream of match results like: It seems the only functional addition in Java8 was .splitAsStream() but that

Java 9 migration issue – package com.mymodule is declared in unnamed module , module ‘newmodule’ does not read it

I have created a multimodule project with the following structure Now i want to use Util.java which is a non modularized code in a modularized module newmodule. i have declared following in newmodule Project is compiling fine, but Intellij is showing module not found and package com.mymodule is declared in unnamed module , module ‘newmodule’ does not read it. How

JAXB not available on Tomcat 9 and Java 9/10

TLDR: On Java 9/10, a web app in Tomcat has no access to JAXB even though its reference implementation is present on the class path. Edit: No, this is not a duplicate of How to resolve java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException in Java 9 – as you can tell by the What I tried section, I already tried the proposed solutions. The Situation

Advertisement