Locating the failing method
When you have determined the lowest optimization level at which the JIT or AOT compiler must compile methods to trigger the failure, you can find out which part of the Java™ program, when compiled, causes the failure. You can then instruct the compiler to limit the workaround to a specific method, class, or package, allowing the compiler to compile the rest of the program as usual. For JIT compiler failures, if the failure occurs with -Xjit:optLevel=noOpt, you can also instruct the compiler to not compile the method or methods that are causing the failure at all.
Before you begin
If you see error output like this example, you can use
it to identify the failing method:
Unhandled exception
Type=Segmentation error vmState=0x00000000
Target=2_30_20050520_01866_BHdSMr (Linux 2.4.21-27.0.2.EL)
CPU=s390x (2 logical CPUs) (0x7b6a8000 RAM)
J9Generic_Signal_Number=00000004 Signal_Number=0000000b Error_Value=4148bf20 Signal_Code=00000001
Handler1=00000100002ADB14 Handler2=00000100002F480C InaccessibleAddress=0000000000000000
gpr0=0000000000000006 gpr1=0000000000000006 gpr2=0000000000000000 gpr3=0000000000000006
gpr4=0000000000000001 gpr5=0000000080056808 gpr6=0000010002BCCA20 gpr7=0000000000000000
......
Compiled_method=java/security/AccessController.toArrayOfProtectionDomains([Ljava/lang/Object;
Ljava/security/AccessControlContext;)[Ljava/security/ProtectionDomain;
The
important lines are:
- vmState=0x00000000
- Indicates that the code that failed was not JVM runtime code.
- Module= or Module_base_address=
- Not in the output (might be blank or zero) because the code was compiled by the JIT, and outside any DLL or library.
Compiled_method=
- Indicates the Java method for which the compiled code was produced.
About this task
Procedure
What to do next
When you have located the failing method, you can disable the JIT or AOT compiler for the failing
method only. For example, if the method java/lang/Math.max(II)I causes the
program to fail when JIT-compiled with optLevel=hot, you can run the program
with:
-Xjit:{java/lang/Math.max(II)I}(optLevel=warm,count=0)
to compile only
the failing method at an optimization level of warm
, but compile all other methods
as usual.If a method fails when it is JIT-compiled at
noOpt
, you can exclude it from
compilation altogether, using the
exclude={<method>} parameter:
-Xjit:exclude={java/lang/Math.max(II)I}
If a method causes the program to fail when AOT code is compiled or loaded from the shared data
cache, exclude the method from AOT compilation and AOT loading using the
exclude={<method>} parameter:
-Xaot:exclude={java/lang/Math.max(II)I}
AOT methods are compiled at the
cold
optimization level only. Preventing AOT compilation or AOT loading is the best
approach for these methods.AOT methods can also be invalidated in the shared cache to prevent loading by using the -Xshareclasses:invalidateAotMethods suboption. For more information, see -Xshareclasses.