Rolled back change that eliminated reflection in logging support, as Proguard was removing the field referenced by native code.
Change on 2018/11/26 by tball
package sun.util.logging;
+import java.lang.reflect.Field;
import java.util.Date;
-// j2objc: jre_emul always has dependency, since both classes are part of a static library.
-/*-[
-#include "java/util/logging/LoggingProxyImpl.h"
-]-*/
-
/**
* Internal API to support JRE implementation to detect if the java.util.logging
* support is available but with no dependency on the java.util.logging
@@ -47,31 +43,26 @@ import java.util.Date;
public class LoggingSupport {
private LoggingSupport() { }
- private static final LoggingProxy proxy = initializeProxy();
-
- // j2objc: simplified with direct access function.
- private static native LoggingProxy initializeProxy() /*-[
- return JavaUtilLoggingLoggingProxyImpl_get_INSTANCE();
- ]-*/;
-
- // static {
- // LoggingProxy p;
- // try {
- // // create a LoggingProxyImpl instance when
- // // java.util.logging classes exist
- // Class<?> c = Class.forName("java.util.logging.LoggingProxyImpl", true, null);
- // Field f = c.getDeclaredField("INSTANCE");
- // f.setAccessible(true);
- // p = (LoggingProxy) f.get(null);
- // } catch (ClassNotFoundException cnf) {
- // p = null;
- // } catch (NoSuchFieldException e) {
- // throw new AssertionError(e);
- // } catch (IllegalAccessException e) {
- // throw new AssertionError(e);
- // }
- // proxy = p;
- // }
+ private static final LoggingProxy proxy;
+
+ static {
+ LoggingProxy p;
+ try {
+ // create a LoggingProxyImpl instance when
+ // java.util.logging classes exist
+ Class<?> c = Class.forName("java.util.logging.LoggingProxyImpl", true, null);
+ Field f = c.getDeclaredField("INSTANCE");
+ f.setAccessible(true);
+ p = (LoggingProxy) f.get(null);
+ } catch (ClassNotFoundException cnf) {
+ p = null;
+ } catch (NoSuchFieldException e) {
+ throw new AssertionError(e);
+ } catch (IllegalAccessException e) {
+ throw new AssertionError(e);
+ }
+ proxy = p;
+ }
/**
* Returns true if java.util.logging support is available.
