在 Android Dalvik VM 中加载 java.util.logging.LogManager 类初始化问题

发布于 2024-08-25 15:35:43 字数 3983 浏览 6 评论 0原文

我已经对 Android 本机库进行了更改并安装了新的 system.img 文件,但现在在启动时出现不相关的错误。我可以通过吞下错误来克服它,但我想知道是否有人可以解释问题是什么。

Logger.java 的 Android 实现声称 它强制 LogManager 初始化,因为它的类初始化代码执行必要的一次性设置。但这种强制初始化会导致 NoClassDefFoundError。我认为这与 Zygote 尚未预加载类有关,但我对整个类加载器和 VM 业务不太熟悉。

如果有人有一些见解,将不胜感激。谢谢。


I/Zygote  ( 1253): Preloading classes...

D/skia    ( 1253): ------ build_power_table 1.4

D/skia    ( 1253): ------ build_power_table 0.714286

W/dalvikvm( 1253): Exception Ljava/lang/StackOverflowError; thrown during Ljava/util/logging/LogManager;.<clinit>

W/dalvikvm( 1253): Exception Ljava/lang/NoClassDefFoundError; thrown during Ljava/security/Security;.<clinit>

W/dalvikvm( 1253): Exception Ljava/lang/ExceptionInInitializerError; thrown during Landroid/net/http/HttpsConnection;.<clinit>

E/Zygote  ( 1253): Error preloading android.net.http.HttpsConnection.

E/Zygote  ( 1253): java.lang.ExceptionInInitializerError

E/Zygote  ( 1253): at java.lang.Class.classForName(Native Method)

E/Zygote  ( 1253): at java.lang.Class.forName(Class.java:237)

E/Zygote  ( 1253): at java.lang.Class.forName(Class.java:183)

E/Zygote  ( 1253): at com.android.internal.os.ZygoteInit.preloadClasses(ZygoteInit.java:295)

E/Zygote  ( 1253): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:590)

E/Zygote  ( 1253): at dalvik.system.NativeStart.main(Native Method)

E/Zygote  ( 1253): Caused by: java.lang.ExceptionInInitializerError

E/Zygote  ( 1253): at javax.net.ssl.KeyManagerFactory$1.run(KeyManagerFactory.java:57)

E/Zygote  ( 1253): at javax.net.ssl.KeyManagerFactory$1.run(KeyManagerFactory.java:56)

E/Zygote  ( 1253): at java.security.AccessController.doPrivilegedImpl(AccessController.java:264)

E/Zygote  ( 1253): at java.security.AccessController.doPrivileged(AccessController.java:84)

E/Zygote  ( 1253): at javax.net.ssl.KeyManagerFactory.getDefaultAlgorithm(KeyManagerFactory.java:55)

E/Zygote  ( 1253): at org.apache.harmony.xnet.provider.jsse.SSLParameters.(SSLParameters.java:142)

E/Zygote  ( 1253): at org.apache.harmony.xnet.provider.jsse.SSLContextImpl.engineInit(SSLContextImpl.java:82)

E/Zygote  ( 1253): at android.net.http.HttpsConnection.initializeEngine(HttpsConnection.java:101)

E/Zygote  ( 1253): at android.net.http.HttpsConnection.(HttpsConnection.java:65)

E/Zygote  ( 1253): ... 6 more

E/Zygote  ( 1253): Caused by: java.lang.NoClassDefFoundError: java.util.logging.LogManager

E/Zygote  ( 1253): at java.util.logging.Logger.initHandler(Logger.java:419)

E/Zygote  ( 1253): at java.util.logging.Logger.log(Logger.java:1094)

E/Zygote  ( 1253): at java.util.logging.Logger.warning(Logger.java:906)

E/Zygote  ( 1253): at org.apache.harmony.luni.util.MsgHelp.loadBundle(MsgHelp.java:61)

E/Zygote  ( 1253): at org.apache.harmony.luni.util.Msg.getString(Msg.java:60)

E/Zygote  ( 1253): at java.io.BufferedInputStream.read(BufferedInputStream.java:316)

E/Zygote  ( 1253): at java.io.FilterInputStream.read(FilterInputStream.java:138)

E/Zygote  ( 1253): at java.io.BufferedInputStream.fillbuf(BufferedInputStream.java:157)

E/Zygote  ( 1253): at java.io.BufferedInputStream.read(BufferedInputStream.java:243)

E/Zygote  ( 1253): at java.util.Properties.load(Properties.java:302)

E/Zygote  ( 1253): at java.security.Security$1.run(Security.java:80)

E/Zygote  ( 1253): at java.security.Security$1.run(Security.java:67)

E/Zygote  ( 1253): at java.security.AccessController.doPrivilegedImpl(AccessController.java:264)

E/Zygote  ( 1253): at java.security.AccessController.doPrivileged(AccessController.java:84)

E/Zygote  ( 1253): at java.security.Security.(Security.java:66)

E/Zygote  ( 1253): ... 15 more

W/dalvikvm( 1253): threadid=3: thread exiting with uncaught exception (group=0x2aac6170)

I've done changes in an Android native library and installed a new system.img file but am now getting an unrelated Error on startup. I can get past it by swallowing the error but I wanted to know if anyone can explain what the issue is.

The Android implementation of Logger.java claims that it is Forcing the LogManager to be initialized since its class init code performs necessary one-time setup. But this forced initialization results in a NoClassDefFoundError. I'm thinking that it has something to do with the class not having been preloaded by Zygote yet but am not that familiar with the whole class loaders and VM business.

If anyone has some insight it would be greatly appreciated. Thanks.


I/Zygote  ( 1253): Preloading classes...

D/skia    ( 1253): ------ build_power_table 1.4

D/skia    ( 1253): ------ build_power_table 0.714286

W/dalvikvm( 1253): Exception Ljava/lang/StackOverflowError; thrown during Ljava/util/logging/LogManager;.<clinit>

W/dalvikvm( 1253): Exception Ljava/lang/NoClassDefFoundError; thrown during Ljava/security/Security;.<clinit>

W/dalvikvm( 1253): Exception Ljava/lang/ExceptionInInitializerError; thrown during Landroid/net/http/HttpsConnection;.<clinit>

E/Zygote  ( 1253): Error preloading android.net.http.HttpsConnection.

E/Zygote  ( 1253): java.lang.ExceptionInInitializerError

E/Zygote  ( 1253): at java.lang.Class.classForName(Native Method)

E/Zygote  ( 1253): at java.lang.Class.forName(Class.java:237)

E/Zygote  ( 1253): at java.lang.Class.forName(Class.java:183)

E/Zygote  ( 1253): at com.android.internal.os.ZygoteInit.preloadClasses(ZygoteInit.java:295)

E/Zygote  ( 1253): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:590)

E/Zygote  ( 1253): at dalvik.system.NativeStart.main(Native Method)

E/Zygote  ( 1253): Caused by: java.lang.ExceptionInInitializerError

E/Zygote  ( 1253): at javax.net.ssl.KeyManagerFactory$1.run(KeyManagerFactory.java:57)

E/Zygote  ( 1253): at javax.net.ssl.KeyManagerFactory$1.run(KeyManagerFactory.java:56)

E/Zygote  ( 1253): at java.security.AccessController.doPrivilegedImpl(AccessController.java:264)

E/Zygote  ( 1253): at java.security.AccessController.doPrivileged(AccessController.java:84)

E/Zygote  ( 1253): at javax.net.ssl.KeyManagerFactory.getDefaultAlgorithm(KeyManagerFactory.java:55)

E/Zygote  ( 1253): at org.apache.harmony.xnet.provider.jsse.SSLParameters.(SSLParameters.java:142)

E/Zygote  ( 1253): at org.apache.harmony.xnet.provider.jsse.SSLContextImpl.engineInit(SSLContextImpl.java:82)

E/Zygote  ( 1253): at android.net.http.HttpsConnection.initializeEngine(HttpsConnection.java:101)

E/Zygote  ( 1253): at android.net.http.HttpsConnection.(HttpsConnection.java:65)

E/Zygote  ( 1253): ... 6 more

E/Zygote  ( 1253): Caused by: java.lang.NoClassDefFoundError: java.util.logging.LogManager

E/Zygote  ( 1253): at java.util.logging.Logger.initHandler(Logger.java:419)

E/Zygote  ( 1253): at java.util.logging.Logger.log(Logger.java:1094)

E/Zygote  ( 1253): at java.util.logging.Logger.warning(Logger.java:906)

E/Zygote  ( 1253): at org.apache.harmony.luni.util.MsgHelp.loadBundle(MsgHelp.java:61)

E/Zygote  ( 1253): at org.apache.harmony.luni.util.Msg.getString(Msg.java:60)

E/Zygote  ( 1253): at java.io.BufferedInputStream.read(BufferedInputStream.java:316)

E/Zygote  ( 1253): at java.io.FilterInputStream.read(FilterInputStream.java:138)

E/Zygote  ( 1253): at java.io.BufferedInputStream.fillbuf(BufferedInputStream.java:157)

E/Zygote  ( 1253): at java.io.BufferedInputStream.read(BufferedInputStream.java:243)

E/Zygote  ( 1253): at java.util.Properties.load(Properties.java:302)

E/Zygote  ( 1253): at java.security.Security$1.run(Security.java:80)

E/Zygote  ( 1253): at java.security.Security$1.run(Security.java:67)

E/Zygote  ( 1253): at java.security.AccessController.doPrivilegedImpl(AccessController.java:264)

E/Zygote  ( 1253): at java.security.AccessController.doPrivileged(AccessController.java:84)

E/Zygote  ( 1253): at java.security.Security.(Security.java:66)

E/Zygote  ( 1253): ... 15 more

W/dalvikvm( 1253): threadid=3: thread exiting with uncaught exception (group=0x2aac6170)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

她比我温柔 2024-09-01 15:35:43

我认为关键实际上是这一行:

W/dalvikvm( 1253): Exception Ljava/lang/StackOverflowError;在 Ljava/util/logging/LogManager; 期间抛出。

我的猜测是该行末尾有一个 ,HTML 转换吞掉了它。该消息表明,在 LogManager 类的类初始化期间,出现 StackOverflowError。这导致了无法上课。后来,当Logger.initHandler()被调用时,系统返回NoClassDefFoundError。

因此,要弄清楚发生了什么,您需要获取 StackOverflowError 的句柄。

I think the key is actually this line:

W/dalvikvm( 1253): Exception Ljava/lang/StackOverflowError; thrown during Ljava/util/logging/LogManager;.

My guess is there's a <clinit> at the end of that line that the HTML conversion swallowed up. The message is saying that, during class initialization of the LogManager class, there was a StackOverflowError. This caused the class to be unavailable. Later on, when Logger.initHandler() got called, the system returned NoClassDefFoundError.

So to figure out what's going on, you need to get a handle on that StackOverflowError.

妄想挽回 2024-09-01 15:35:43

尝试从框架/基础/预加载类中删除有问题的类,然后重建框架,并刷新您的设备。如果您从 android.net.http 中删除所有日志记录类和类,您将有最大的成功机会。

这可能会对性能产生微小影响,因为删除的类不会在应用程序之间共享。

Try removing the offending classes from frameworks/base/preloaded-classes, then rebuild the framework, and flash your device. You'll have the best chance at success if you remove all logging classes and classes from android.net.http.

This may have a tiny performance impact because the removed classes will not be shared between applications.

意中人 2024-09-01 15:35:43

正如 fadden 所指出的,在 LogManager 的类初始化期间,类加载器运行了一些其他具有堆栈溢出的代码,因此 LogManager 的类初始化失败。

我不知道在 android 调试环境中可以使用哪些工具,但我会:

  1. 设置“java -verbose”的等效项(是的,我知道 dalvikvm 不是“真正的”java。 - 但它可能具有相同的功能某种标志)您正在寻找作为 LogManager clinit 的一部分加载的其他类。
  2. 在 LogManager 类加载上设置断点并单步执行代码。
  3. 在 StackOverflowError 上设置断点。 eclipse有这个能力。在断点视图上查找 [J!] - 再次不知道 android 调试环境是否具有此功能,但它似乎相当基本。
  4. 查看logging.properties 文件中列出的类 - 问题可能出在这些类之一的clinit
  5. 尝试空的logging.properties 文件中。
  6. 在 LogManager.readConfiguration() 中设置断点,看看是否达到了这一点。

As fadden was indicating, during the class initialization of LogManager, the class loader ran some other code that had a stackoverflow and thus the class initialization of LogManager failed.

I don't know what tools you have available in the android debug environment, but I would:

  1. set the equivalent of "java -verbose" (yes I know that dalvikvm isn't "really" java. - but it probably has the same sort of flag ) You are looking for what other classes get loaded as part of the LogManager clinit.
  2. set a breakpoint on LogManager classloading and step through the code.
  3. set a breakpoint on StackOverflowError. eclipse has this ability. Look for a [J!] on the breakpoint view - once again don't know if android debug environment has this capability, but it seems rather basic.
  4. Look at the classes listed in the logging.properties file - problem might be in one of those classes' clinit
  5. try an empty logging.properties file.
  6. set breakpoint in LogManager.readConfiguration() to see if you get that far.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文