- 필수 기능
- 시작하기
- Glossary
- 표준 속성
- Guides
- Agent
- 통합
- 개방형텔레메트리
- 개발자
- Administrator's Guide
- API
- Datadog Mobile App
- CoScreen
- Cloudcraft
- 앱 내
- 서비스 관리
- 인프라스트럭처
- 애플리케이션 성능
- APM
- Continuous Profiler
- 스팬 시각화
- 데이터 스트림 모니터링
- 데이터 작업 모니터링
- 디지털 경험
- 소프트웨어 제공
- 보안
- AI Observability
- 로그 관리
- 관리
",t};e.buildCustomizationMenuUi=t;function n(e){let t='
",t}function s(e){let n=e.filter.currentValue||e.filter.defaultValue,t='${e.filter.label}
`,e.filter.options.forEach(s=>{let o=s.id===n;t+=``}),t+="${e.filter.label}
`,t+=`ID: java-code-style/avoid-using-native-code
Language: Java
Severity: Notice
Category: Code Style
When Java applications use native code, typically through the Java Native Interface (JNI) and methods like System.loadLibrary()
or System.load()
, it introduces a strong dependency on platform-specific binaries. This practice significantly reduces the portability of the application, as the native libraries must be compiled and distributed for each target operating system and architecture. It also increases deployment complexity, makes debugging more challenging, and can lead to instability or crashes if native code interactions are not meticulously managed.
To enhance portability and maintainability, favor pure Java solutions over native code whenever possible. If interacting with system-specific features or achieving critical performance gains necessitates native calls, consider abstracting them behind an interface to minimize their direct impact on the codebase. Prioritize using well-established, cross-platform libraries or external services that handle native interactions internally, rather than directly managing System.loadLibrary()
calls within your application logic.
public class Foo {
public Foo() {
System.loadLibrary("nativelib");
}
static {
System.loadLibrary("nativelib");
}
public void foo() throws SecurityException, NoSuchMethodException {
System.loadLibrary("nativelib");
}
}
public class Bar {
public void baz() {
System.out.println("Executing pure Java code without native dependencies.");
// No System.loadLibrary or System.load calls here
}
}