Enhance footprint for array initialization

Ulf Zibis Ulf.Zibis at gmx.de
Mon Sep 1 10:19:55 PDT 2008


I my code I have following array initialization:
(from: 
https://java-nio-charset-enhanced.dev.java.net/source/browse/java-nio-charset-enhanced/tags/sun_io_CharacterEncoding_using_String[][]/src/sun/io/CharacterEncoding.java?rev=&view=markup)

    private static final String[][] extendedAliasMappings = {
        {"8859_1",                "ISO8859_1"},
        {"iso_8859-1:1987",       "ISO8859_1"},
        {"iso-ir-100",            "ISO8859_1"},
        {"iso_8859-1",            "ISO8859_1"},
        // + 475 more pairs ...
    }

In the class file the following block is repeated 475 times:
(from: 
https://java-nio-charset-enhanced.dev.java.net/source/browse/java-nio-charset-enhanced/tags/sun_io_CharacterEncoding_using_String%5B%5D%5B%5D/docs/javap.out/javap%20CharacterEncoding(String%5B%5D%5B%5D).out?rev=&view=markup)

   874:    dup
   875:    iconst_0
   876:    iconst_2
   877:    anewarray    #10; //class java/lang/String
   880:    dup
   881:    iconst_0
   882:    ldc    #40; //String 8859_1
   884:    aastore
   885:    dup
   886:    iconst_1
   887:    ldc    #41; //String ISO8859_1
   889:    aastore
   890:    aastore

IMHO it would be better, to initialize the String[][] by a loop, instead 
inlining those bytecodes 475 times. This would considerably decrease the 
footprint of the class file.

Is there any chance, we could have this in the future?

Regards,

-Ulf





More information about the hotspot-dev mailing list