< prev index next >

src/java.base/share/classes/jdk/internal/jimage/decompressor/StringSharingDecompressor.java

Print this page




  47  */
  48 public class StringSharingDecompressor implements ResourceDecompressor {
  49 
  50     public static final int EXTERNALIZED_STRING = 23;
  51     public static final int EXTERNALIZED_STRING_DESCRIPTOR = 25;
  52 
  53     private static final int CONSTANT_Utf8 = 1;
  54     private static final int CONSTANT_Integer = 3;
  55     private static final int CONSTANT_Float = 4;
  56     private static final int CONSTANT_Long = 5;
  57     private static final int CONSTANT_Double = 6;
  58     private static final int CONSTANT_Class = 7;
  59     private static final int CONSTANT_String = 8;
  60     private static final int CONSTANT_Fieldref = 9;
  61     private static final int CONSTANT_Methodref = 10;
  62     private static final int CONSTANT_InterfaceMethodref = 11;
  63     private static final int CONSTANT_NameAndType = 12;
  64     private static final int CONSTANT_MethodHandle = 15;
  65     private static final int CONSTANT_MethodType = 16;
  66     private static final int CONSTANT_InvokeDynamic = 18;


  67 
  68     private static final int[] SIZES = new int[20];
  69 
  70     static {
  71 
  72         //SIZES[CONSTANT_Utf8] = XXX;
  73         SIZES[CONSTANT_Integer] = 4;
  74         SIZES[CONSTANT_Float] = 4;
  75         SIZES[CONSTANT_Long] = 8;
  76         SIZES[CONSTANT_Double] = 8;
  77         SIZES[CONSTANT_Class] = 2;
  78         SIZES[CONSTANT_String] = 2;
  79         SIZES[CONSTANT_Fieldref] = 4;
  80         SIZES[CONSTANT_Methodref] = 4;
  81         SIZES[CONSTANT_InterfaceMethodref] = 4;
  82         SIZES[CONSTANT_NameAndType] = 4;
  83         SIZES[CONSTANT_MethodHandle] = 3;
  84         SIZES[CONSTANT_MethodType] = 2;
  85         SIZES[CONSTANT_InvokeDynamic] = 4;


  86     }
  87 
  88     public static int[] getSizes() {
  89         return SIZES.clone();
  90     }
  91 
  92     @SuppressWarnings("fallthrough")
  93     public static byte[] normalize(StringsProvider provider, byte[] transformed,
  94             int offset) throws IOException {
  95         DataInputStream stream = new DataInputStream(new ByteArrayInputStream(transformed,
  96                 offset, transformed.length - offset));
  97         ByteArrayOutputStream outStream = new ByteArrayOutputStream(transformed.length);
  98         DataOutputStream out = new DataOutputStream(outStream);
  99         byte[] header = new byte[8]; //maginc/4, minor/2, major/2
 100         stream.readFully(header);
 101         out.write(header);
 102         int count = stream.readUnsignedShort();
 103         out.writeShort(count);
 104         for (int i = 1; i < count; i++) {
 105             int tag = stream.readUnsignedByte();




  47  */
  48 public class StringSharingDecompressor implements ResourceDecompressor {
  49 
  50     public static final int EXTERNALIZED_STRING = 23;
  51     public static final int EXTERNALIZED_STRING_DESCRIPTOR = 25;
  52 
  53     private static final int CONSTANT_Utf8 = 1;
  54     private static final int CONSTANT_Integer = 3;
  55     private static final int CONSTANT_Float = 4;
  56     private static final int CONSTANT_Long = 5;
  57     private static final int CONSTANT_Double = 6;
  58     private static final int CONSTANT_Class = 7;
  59     private static final int CONSTANT_String = 8;
  60     private static final int CONSTANT_Fieldref = 9;
  61     private static final int CONSTANT_Methodref = 10;
  62     private static final int CONSTANT_InterfaceMethodref = 11;
  63     private static final int CONSTANT_NameAndType = 12;
  64     private static final int CONSTANT_MethodHandle = 15;
  65     private static final int CONSTANT_MethodType = 16;
  66     private static final int CONSTANT_InvokeDynamic = 18;
  67     private static final int CONSTANT_Module = 19;
  68     private static final int CONSTANT_Package = 20;
  69 
  70     private static final int[] SIZES = new int[21];
  71 
  72     static {
  73 
  74         //SIZES[CONSTANT_Utf8] = XXX;
  75         SIZES[CONSTANT_Integer] = 4;
  76         SIZES[CONSTANT_Float] = 4;
  77         SIZES[CONSTANT_Long] = 8;
  78         SIZES[CONSTANT_Double] = 8;
  79         SIZES[CONSTANT_Class] = 2;
  80         SIZES[CONSTANT_String] = 2;
  81         SIZES[CONSTANT_Fieldref] = 4;
  82         SIZES[CONSTANT_Methodref] = 4;
  83         SIZES[CONSTANT_InterfaceMethodref] = 4;
  84         SIZES[CONSTANT_NameAndType] = 4;
  85         SIZES[CONSTANT_MethodHandle] = 3;
  86         SIZES[CONSTANT_MethodType] = 2;
  87         SIZES[CONSTANT_InvokeDynamic] = 4;
  88         SIZES[CONSTANT_Module] = 2;
  89         SIZES[CONSTANT_Package] = 2;
  90     }
  91 
  92     public static int[] getSizes() {
  93         return SIZES.clone();
  94     }
  95 
  96     @SuppressWarnings("fallthrough")
  97     public static byte[] normalize(StringsProvider provider, byte[] transformed,
  98             int offset) throws IOException {
  99         DataInputStream stream = new DataInputStream(new ByteArrayInputStream(transformed,
 100                 offset, transformed.length - offset));
 101         ByteArrayOutputStream outStream = new ByteArrayOutputStream(transformed.length);
 102         DataOutputStream out = new DataOutputStream(outStream);
 103         byte[] header = new byte[8]; //maginc/4, minor/2, major/2
 104         stream.readFully(header);
 105         out.write(header);
 106         int count = stream.readUnsignedShort();
 107         out.writeShort(count);
 108         for (int i = 1; i < count; i++) {
 109             int tag = stream.readUnsignedByte();


< prev index next >