Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[INFO] 테스트할 때 뜨는 JAVA agent 경고 및 OpenJDK VM Sharing 경고에 대하여 #16

Open
kimminkyeu opened this issue Apr 15, 2024 · 1 comment · May be fixed by #17
Open
Assignees
Labels

Comments

@kimminkyeu
Copy link
Contributor

kimminkyeu commented Apr 15, 2024

경고가 뭔지 궁금해서 찾아본 것 공유합니다.

1️⃣ Dynamically loaded JAVA agent 경고

결론 : JDK 버전을 상향시킬 것이 아니라면 무시해도 되는 경고입니다.

image
JDK 향후 버전에 DynamicAgentLoading 을 제거할 계획이라서 이 기능에 의존하는 라이브러리를 쓸 경우 뜨는 경고입니다.

참고 : https://openjdk.org/jeps/451 “Prepare to Disallow the Dynamic Loading of Agents”

image
Dynamic Agent는 Mockito와 같은 테스트 프레임워크에서 사용합니다. Mockito는 더 자세히 말하면 Byte Buddy agent loading 에 의존하는데, 이게 뭐냐면, Lombok처럼 컴파일 타임에 코드를 생성하는게 아니라, 런타임에 바이트코드를 수정하는 방식입니다.

아래는 Mockito 깃허브에 올라온 이슈입니다.

I'd just like to remind again that libraries must never dynamically load an agent, even if the -XX:+EnableDynamicAgentLoading is present.
The -XX:+EnableDynamicAgentLoading flag is intended only for tools. True, it currently won't block a library from loading an agent, but that may well change at any time and without further notice. As far as the JDK is concerned, libraries do not dynamically load agents, the JDK may rely on that assumption, and the JDK may enforce it at any time. There is only one way for a library to employ an agent and that is with -javaagent. Depending on -XX:+EnableDynamicAgentLoading now will likely just cause further breakage and further need to change things down the line.

메시지 끄는 방법 : gradle 설정에 아래 내용 추가

// JDK 향후 버전에서는 DynamicAgentLoading이 없어질 예정이나, 현재 JDK에선 아직 아님으로 일단 아래 옵션을 이용한다.
tasks.withType<Test> {
  jvmArgs("-XX:+EnableDynamicAgentLoading")
}

2️⃣OpenJDK 64-bit Server VM warning: Sharing is only supported for boot loader .... 경고

결론 : 그냥 뜨게 냅둬야 합니다. 어쩔 수 없음. 이거 끄는 옵션이 -Xshare:off 인데, 앱 시작 성능이 저하됨

해당 경고를 출력하는 jdk 코드입니다. (재미로 보셈)
image
OpenJDK based JDK를 사용할 경우 Class Data Sharing(CDS)가 일부 비활성화되서 뜨는 경고 메시지입니다.
앱이 빨리 시작되도록 하는 최적화 방법인데, 자세한 설명은 아래에 있습니다.

“Application Class-Data Sharing" is an optimization where users can record class load metadata into a "class-data archive". Launching your application again reads from this archive so that the application starts faster.

As of Java 12, OpenJDK based JDKs have a class-data archive for JDK classes. Because the Datadog agent appends to the bootstrap classpath, the class-data archive is incorrect for the system class loader.

The warning is telling you that the class data optimization is partially turned off.

The only way to get rid of the warning is to turn the optimization off fully with "-Xshare:off".
However, this could potentially worsen the startup performance of your application.

@kimminkyeu kimminkyeu added the FEAT New feature or request label Apr 15, 2024
@kimminkyeu kimminkyeu self-assigned this Apr 15, 2024
@kimminkyeu kimminkyeu added INFO and removed FEAT New feature or request labels Apr 15, 2024
@POKUDING
Copy link

알아보시느라 고생하셨습니다. 감사합니다!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants