简体   繁体   中英

JavaAgent on Java 9

Prior to java 9, the monitoring JavaAgent were loaded into the JVM by boostrapClassloader so that the monitored applications could access them

With Java 9 modular architecture, only java.base module gets loaded in Bootstrap classloader and so, Java agent can access only classes inside java.base? It can't access anything outside java.base by default?

What is required to be changed inside javaAgent in order to access other modules like java.sql?

I just validated this for the latest build and when using

Instrumentation::appendToBootstrapClassLoaderSearch

The class is added to the bootstrap loader ( null ) and loaded into the unnamed module of this loader. This is true for Java 9, ea-176.

Here's a link the java.lang.instrument package description in the JDK 9 EA builds:

http://download.java.net/java/jdk9/docs/api/java/lang/instrument/package-summary.html

The section "Loading agent classes and the modules/classes available to the agent class" should help with the discussion here.

As regards the java.sql module then it is one of several "non-core" modules that are no longer defined to the boot loader. Moving these modules to the platform class loader means they can run with reduced permissions and so helps with the overall security of the platform. This should be completely transparent to applications and libraries on the class path and should only be noticeable by code that (a) runs with -Xbootclasspath/a, (b) creates a custom class with null as the parent, and (c) agent supporting classes added to the boot class loader search with the Boot-Class-Path attribute or the appendToBootstrapClassLoaderSearch API.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM