Category : java9

Order This article mainly studies how to run springboot2 on docker’s java9 image and streamline jdk. maven <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.0.0.RC2</version> <relativePath/> <!– lookup parent from repository –> </parent> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <java.version>9</java.version> <start-class>com.example.demo.DemoApplication</start-class> </properties> Note that only version 2 of springboot can support java9, and this java.version is set to 9.The version maven uses ..

Read more

Order This article mainly narrates the knowledge points that java9 module system must know. Modules and modules module Module are mainly divided into the following two types: main module Module containing the main method, specified by –module or -m root module Specifies the root module that the module system parses. module dependencies are parsed from ..

Read more

Order This paper mainly studies how to build java9 multi module and service instance in maven. maven The whole project is the same as the traditional maven multi-module project structure. One module of java9 corresponds to one module of maven project. The following is the pom file under the root directory: <?xml version=”1.0″ encoding=”UTF-8″?> <project ..

Read more

Order This article mainly studies some matters needing attention in migrating to java9. Migration type 1. The code is not modularized. First, migrate to jdk9 to make good use of the api of jdk92. The code is also migrated modularly. Several Points for Attention Unreadable class For example, sun.security.x509 is included in java.base module in ..

Read more

Order This paper mainly studies the difference between java9 opens and exports Open and exports open open module It is mainly used to solve the deep reflection problem. the function of open is to indicate that all packages under this module allow deep reflection (Including public and private types)However, at compile time, only packages declared ..

Read more

Order This article mainly analyzes java9 module related options Module classification unnamed module All jars in classpath (whether modular or not) together form an unnamed module Unnamed modules declare dependency on all named modules and exports all their own packages, but a named module cannot declare dependency on unnamed modules. If a package is defined ..

Read more

Order This article mainly studiesJEP 102: Process API Updates ProcessHandle /Library/Java/JavaVirtualMachines/jdk-9.0.4.jdk/Contents/Home/lib/src.zip! /java.base/java/lang/ProcessHandle.java Java9 introduces ProcessHandle /** * ProcessHandle identifies and provides control of native processes. Each * individual process can be monitored for liveness, list its children, * get information about the process or destroy it. * By comparison, {@link java.lang.Process Process} instances were started ..

Read more

Order This article mainly studiesJEP 259: Stack-Walking API StackWalker Java9 added this class to provide a standard API for accessing the current thread stack. Previously, only Throwable::getStackTrace, Thread::getStackTrace and SecurityManager:: GetClassContext provided methods to obtain the thread stack. StackWalker.Option /Library/Java/JavaVirtualMachines/jdk-9.0.4.jdk/Contents/Home/lib/src.zip! /java.base/java/lang/StackWalker.java /** * Stack walker option to configure the {@linkplain StackFrame stack frame} * information ..

Read more

Order This article mainly studiesJEP 193: Variable Handles Variable Handles The API of Variable Handles is mainly used to replace the functions of java.util.concurrent.atomic package and sun.misc.Unsafe class. A variable handle is a variable type reference used to read and write variables in a series of access modes. Supported variables include instance variables, static members, ..

Read more

Order This article mainly studiesJEP 238: Multi-Release JAR Files multi-release jar (MR JAR) Java9 newly supports the functions of multi-release jar, including jar, javac, javap, jdeps and other commands. The so-called multi-release jar can include multiple jdk versions. At runtime, the JVM loads a class that conforms to the version according to the current environment. ..

Read more

Order This article mainly studiesJEP 248: Make G1 the Default Garbage Collector Default garbage collector Java9 abandoned the CMS garbage collector and upgraded G1 to the default garbage collector, replacing the original throughput-first ParallelOldGC Region The biggest difference between G1 and previous garbage collectors is the introduction of Region. G1 is also based on generation ..

Read more

Order This article focuses on how to confuse java9 code with proguard maven <plugin> <groupId>com.github.wvengen</groupId> <artifactId>proguard-maven-plugin</artifactId> <executions> <execution> <phase>package</phase> <goals><goal>proguard</goal></goals> </execution> </executions> <configuration> <proguardVersion>6.0.1</proguardVersion> <injar>${project.build.finalName}.jar</injar> <outjar>${project.build.finalName}.jar</outjar> <inFilter>!META-INF/maven/**,!module-info.class</inFilter> <obfuscate>true</obfuscate> <proguardInclude>${project.basedir}/proguard.cfg</proguardInclude> <libs> <lib>${java.home}/jmods/java.base.jmod(!**.jar;!module-info.class)</lib> </libs> </configuration> <dependencies> <dependency> <groupId>net.sf.proguard</groupId> <artifactId>proguard-base</artifactId> <version>6.0.1</version> <scope>runtime</scope> </dependency> </dependencies> </plugin> Proguard-base version 6.0.1 is used here proguard.cfg -target 9 -dontshrink -dontoptimize -useuniqueclassmembernames -adaptclassstrings ..

Read more