ArrayIndexOutOfBoundsException as following was hiding in ClhsdbPrintAll.java.
See attached .jtr file in JBS.
java.lang.ArrayIndexOutOfBoundsException: 7 6
at
jdk.hotspot.agent/sun.jvm.hotspot.oops.ResolvedMethodArray.getAt(ResolvedMethodArray.java:60)
at
jdk.hotspot.agent/sun.jvm.hotspot.oops.ConstantPoolCache.getMethodEntryAt(ConstantPoolCache.java:99)
at
jdk.hotspot.agent/sun.jvm.hotspot.interpreter.BytecodeWithCPIndex.indexForFieldOrMethod(BytecodeWithCPIndex.java:57)
at
jdk.hotspot.agent/sun.jvm.hotspot.interpreter.BytecodeGetPut.toString(BytecodeGetPut.java:58)
at
jdk.hotspot.agent/sun.jvm.hotspot.ui.classbrowser.HTMLGenerator$1.visit(HTMLGenerator.java:685)
at
jdk.hotspot.agent/sun.jvm.hotspot.interpreter.BytecodeDisassembler.decode(BytecodeDisassembler.java:156)
at
jdk.hotspot.agent/sun.jvm.hotspot.ui.classbrowser.HTMLGenerator.genHTML(HTMLGenerator.java:659)
at
jdk.hotspot.agent/sun.jvm.hotspot.CommandProcessor$18$1.visit(CommandProcessor.java:876)
at
jdk.hotspot.agent/sun.jvm.hotspot.classfile.ClassLoaderData.classesDo(ClassLoaderData.java:113)
at
jdk.hotspot.agent/sun.jvm.hotspot.classfile.ClassLoaderDataGraph.classesDo(ClassLoaderDataGraph.java:84)
at
jdk.hotspot.agent/sun.jvm.hotspot.CommandProcessor$18.doit(CommandProcessor.java:869)
at
jdk.hotspot.agent/sun.jvm.hotspot.CommandProcessor.executeCommand(CommandProcessor.java:2051)
at
jdk.hotspot.agent/sun.jvm.hotspot.CommandProcessor.executeCommand(CommandProcessor.java:2021)
at
jdk.hotspot.agent/sun.jvm.hotspot.CommandProcessor.run(CommandProcessor.java:1892)
at jdk.hotspot.agent/sun.jvm.hotspot.CLHSDB.run(CLHSDB.java:113)
at jdk.hotspot.agent/sun.jvm.hotspot.CLHSDB.main(CLHSDB.java:45)
at jdk.hotspot.agent/sun.jvm.hotspot.SALauncher.runCLHSDB(SALauncher.java:285)
at jdk.hotspot.agent/sun.jvm.hotspot.SALauncher.main(SALauncher.java:507)
AFAICS all of failures are caused by `getfield` bytecode. We can see it in
`javap`, but in SA, another bytecode values (e.g. "234") were detected. Thus
`getfield` would not be handled as field operation at folloing code in
BytecodeWithCPIndex.java, eventually the exception was thrown.
if (cpCache == null) {
return cpCacheIndex;
} else if (code() == Bytecodes._invokedynamic) {
return cpCache.getIndyEntryAt(cpCacheIndex).getConstantPoolIndex();
} else if (Bytecodes.isFieldCode(code())) {
return cpCache.getFieldEntryAt(cpCacheIndex).getConstantPoolIndex();
} else {
return cpCache.getMethodEntryAt(cpCacheIndex).getConstantPoolIndex();
}
In Bytecodes.java, following values should be handled as field operations.
`Bytecodes.isFieldCode()` should identify them.
public static final int _getstatic = 178; // 0xb2
public static final int _putstatic = 179; // 0xb3
public static final int _getfield = 180; // 0xb4
public static final int _putfield = 181; // 0xb5
:
public static final int number_of_java_codes = 203;
// JVM bytecodes
public static final int _fast_agetfield = number_of_java_codes;
public static final int _fast_bgetfield = 204;
public static final int _fast_cgetfield = 205;
public static final int _fast_dgetfield = 206;
public static final int _fast_fgetfield = 207;
public static final int _fast_igetfield = 208;
public static final int _fast_lgetfield = 209;
public static final int _fast_sgetfield = 210;
public static final int _fast_aputfield = 211;
public static final int _fast_bputfield = 212;
public static final int _fast_zputfield = 213;
public static final int _fast_cputfield = 214;
public static final int _fast_dputfield = 215;
public static final int _fast_fputfield = 216;
public static final int _fast_iputfield = 217;
public static final int _fast_lputfield = 218;
public static final int _fast_sputfield = 219;
:
// Bytecodes rewritten at CDS dump time
public static final int _nofast_getfield = 234;
public static final int _nofast_putfield = 235;
Maybe this is long-standing bug because the exception could not be caught jtreg
tests, thus I updated testcase to check stderr. But ClhsdbDumpheap.java and
ClhsdbJhisto.java would ignore this because they prints message into stderr or
checks strings in stderr.
---------
- [x] I confirm that I make this contribution in accordance with the [OpenJDK
Interim AI Policy](https://openjdk.org/legal/ai).
-------------
Commit messages:
- 8382485: ArrayIndexOutOfBoundsException was hiding in ClhsdbPrintAll.jtr
Changes: https://git.openjdk.org/jdk/pull/30808/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=30808&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8382485
Stats: 18 lines in 4 files changed: 15 ins; 0 del; 3 mod
Patch: https://git.openjdk.org/jdk/pull/30808.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/30808/head:pull/30808
PR: https://git.openjdk.org/jdk/pull/30808