RFR: 8364360: Defining hidden class with no room in constant pool crashes the VM [v2]

Chen Liang liach at openjdk.org
Mon Oct 27 23:32:01 UTC 2025


On Mon, 27 Oct 2025 12:40:02 GMT, Coleen Phillimore <coleenp at openjdk.org> wrote:

>> test/hotspot/jtreg/runtime/ClassFile/HiddenClassesTest.java line 44:
>> 
>>> 42:         var cw = new ClassWriter(0);
>>> 43:         cw.visit(V17, ACC_PUBLIC, "Hidden", null, "java/lang/Object", null);
>>> 44:         for (int i = 0; i < 65530; i++) {
>> 
>> Why 65530? An empty class definition already has 12 CP entries when compiled by javac.
>
> This is a magic number.  65536-5 gets CFE: class too large, 65536-7 doesn't get an CFE.  Only 65536-6 caused the overflow.  This is asm so asm may only be adding 6 entries.  I kept the test as ASM rather than using ClassFile API because it might be good to backport this.

If we have such a sensitive dependency on the CP size, we might consider opening up the `symbolTable.getConstantPoolCount()` on the `ClassWriter` for better testing, or use the ClassFile API that has a similar fine-grained control over constant pool sizes.

I can help you update ASM or rewrite in ClassFile API if the Java code is too complex for you.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/27964#discussion_r2467431683


More information about the hotspot-runtime-dev mailing list