为什么java.base中有一些方法不能被AOT编译器编译
Why are there some methods in java.base cannot be compiled by AOT compiler
根据 JEP-295 (http://openjdk.java.net/jeps/295)
java.base中有一些方法导致编译失败,为什么?
如果有人能帮助我,让我了解 Openjdk AOT 编译器的限制,我将不胜感激。
查看 documentation 您正在 link 前往:
Current AOT limitations ...
May not compile java code which uses dynamically generated classes and bytecode (lambda expressions, invoke dynamic).
These limitations may be addressed in future releases.
因此有两个潜在的解释:
- 未通过编译的方法属于已知限制
- 否则,“全新的、实验性”产品中的错误
很可能“选项 2”是更好的解释 - 请再次查看您的 link。
它包含编译失败的方法列表,以及发生的错误:
cat java.base-list.txt
# jaotc: java.lang.WhosebugError
exclude sun.util.resources.LocaleNames.getContents()[[Ljava/lang/Object;
exclude sun.util.resources.TimeZoneNames.getContents()[[Ljava/lang/Object;
exclude sun.util.resources.cldr.LocaleNames.getContents()[[Ljava/lang/Object;
exclude sun.util.resources..*.LocaleNames_.*.getContents\(\)\[\[Ljava/lang/Object;
exclude sun.util.resources..*.LocaleNames_.*_.*.getContents\(\)\[\[Ljava/lang/Object;
exclude sun.util.resources..*.TimeZoneNames_.*.getContents\(\)\[\[Ljava/lang/Object;
exclude sun.util.resources..*.TimeZoneNames_.*_.*.getContents\(\)\[\[Ljava/lang/Object;
# java.lang.Error: Trampoline must not be defined by the bootstrap classloader
exclude sun.reflect.misc.Trampoline.<clinit>()V
exclude sun.reflect.misc.Trampoline.invoke(Ljava/lang/reflect/Method;Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;
# JVM asserts
exclude com.sun.crypto.provider.AESWrapCipher.engineUnwrap([BLjava/lang/String;I)Ljava/security/Key;
exclude sun.security.ssl.*
exclude sun.net.RegisteredDomain.<clinit>()V
# Huge methods
exclude jdk.internal.module.SystemModules.descriptors()[Ljava/lang/module/ModuleDescriptor;
并且当您检查来源时,例如 getContents() - 那里没有 lambda。
所以编译失败的方法很可能是由于新编译器“尚未准备好”以成功编译编译任意Java源码!
根据 JEP-295 (http://openjdk.java.net/jeps/295)
java.base中有一些方法导致编译失败,为什么?
如果有人能帮助我,让我了解 Openjdk AOT 编译器的限制,我将不胜感激。
查看 documentation 您正在 link 前往:
Current AOT limitations ...
May not compile java code which uses dynamically generated classes and bytecode (lambda expressions, invoke dynamic).
These limitations may be addressed in future releases.
因此有两个潜在的解释:
- 未通过编译的方法属于已知限制
- 否则,“全新的、实验性”产品中的错误
很可能“选项 2”是更好的解释 - 请再次查看您的 link。
它包含编译失败的方法列表,以及发生的错误:
cat java.base-list.txt
# jaotc: java.lang.WhosebugError
exclude sun.util.resources.LocaleNames.getContents()[[Ljava/lang/Object;
exclude sun.util.resources.TimeZoneNames.getContents()[[Ljava/lang/Object;
exclude sun.util.resources.cldr.LocaleNames.getContents()[[Ljava/lang/Object;
exclude sun.util.resources..*.LocaleNames_.*.getContents\(\)\[\[Ljava/lang/Object;
exclude sun.util.resources..*.LocaleNames_.*_.*.getContents\(\)\[\[Ljava/lang/Object;
exclude sun.util.resources..*.TimeZoneNames_.*.getContents\(\)\[\[Ljava/lang/Object;
exclude sun.util.resources..*.TimeZoneNames_.*_.*.getContents\(\)\[\[Ljava/lang/Object;
# java.lang.Error: Trampoline must not be defined by the bootstrap classloader
exclude sun.reflect.misc.Trampoline.<clinit>()V
exclude sun.reflect.misc.Trampoline.invoke(Ljava/lang/reflect/Method;Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;
# JVM asserts
exclude com.sun.crypto.provider.AESWrapCipher.engineUnwrap([BLjava/lang/String;I)Ljava/security/Key;
exclude sun.security.ssl.*
exclude sun.net.RegisteredDomain.<clinit>()V
# Huge methods
exclude jdk.internal.module.SystemModules.descriptors()[Ljava/lang/module/ModuleDescriptor;
并且当您检查来源时,例如 getContents() - 那里没有 lambda。
所以编译失败的方法很可能是由于新编译器“尚未准备好”以成功编译编译任意Java源码!