mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-18 18:14:38 +02:00
8266391: Replace use of reflection in jdk.internal.platform.Metrics
Reviewed-by: redestad
This commit is contained in:
parent
020236cb98
commit
3544a9d0e4
4 changed files with 95 additions and 10 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -55,15 +55,7 @@ public interface Metrics {
|
|||
* @return Metrics object or null if not supported on this platform.
|
||||
*/
|
||||
public static Metrics systemMetrics() {
|
||||
try {
|
||||
Class<?> c = Class.forName("jdk.internal.platform.CgroupMetrics");
|
||||
Method m = c.getMethod("getInstance");
|
||||
return (Metrics) m.invoke(null);
|
||||
} catch (ClassNotFoundException e) {
|
||||
return null;
|
||||
} catch (ReflectiveOperationException e) {
|
||||
throw new InternalError(e);
|
||||
}
|
||||
return SystemMetrics.instance();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue