< prev index next >

test/lib/jdk/test/lib/hprof/model/JavaValueArray.java

Print this page

  1 /*
  2  * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
  3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  4  *
  5  * This code is free software; you can redistribute it and/or modify it
  6  * under the terms of the GNU General Public License version 2 only, as
  7  * published by the Free Software Foundation.  Oracle designates this
  8  * particular file as subject to the "Classpath" exception as provided
  9  * by Oracle in the LICENSE file that accompanied this code.
 10  *
 11  * This code is distributed in the hope that it will be useful, but WITHOUT
 12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 14  * version 2 for more details (a copy is included in the LICENSE file that
 15  * accompanied this code).
 16  *
 17  * You should have received a copy of the GNU General Public License version
 18  * 2 along with this work; if not, write to the Free Software Foundation,
 19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 20  *
 21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 22  * or visit www.oracle.com if you need additional information or have any

 52                 return "boolean[]";
 53             case 'C':
 54                 return "char[]";
 55             case 'S':
 56                 return "short[]";
 57             case 'I':
 58                 return "int[]";
 59             case 'F':
 60                 return "float[]";
 61             case 'J':
 62                 return "long[]";
 63             case 'D':
 64                 return "double[]";
 65             default:
 66                 throw new RuntimeException("invalid array element sig: " + sig);
 67         }
 68     }
 69 
 70     private static int elementSize(byte type) {
 71         switch (type) {
 72             case T_BYTE:
 73             case T_BOOLEAN:
 74                 return 1;
 75             case T_CHAR:
 76             case T_SHORT:
 77                 return 2;
 78             case T_INT:
 79             case T_FLOAT:
 80                 return 4;
 81             case T_LONG:
 82             case T_DOUBLE:
 83                 return 8;
 84             default:
 85                 throw new RuntimeException("invalid array element type: " + type);
 86         }
 87     }
 88 
 89     /*
 90      * Java primitive array record (HPROF_GC_PRIM_ARRAY_DUMP) looks
 91      * as below:
 92      *
 93      *    object ID
 94      *    stack trace serial number (int)
 95      *    number of elements (int)
 96      *    element type (byte)
 97      *    array data
 98      */
 99     @Override
100     protected final long readValueLength() throws IOException {
101         long offset = getOffset() + idSize() + 4;
102         // length of the array in elements

  1 /*
  2  * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
  3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  4  *
  5  * This code is free software; you can redistribute it and/or modify it
  6  * under the terms of the GNU General Public License version 2 only, as
  7  * published by the Free Software Foundation.  Oracle designates this
  8  * particular file as subject to the "Classpath" exception as provided
  9  * by Oracle in the LICENSE file that accompanied this code.
 10  *
 11  * This code is distributed in the hope that it will be useful, but WITHOUT
 12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 14  * version 2 for more details (a copy is included in the LICENSE file that
 15  * accompanied this code).
 16  *
 17  * You should have received a copy of the GNU General Public License version
 18  * 2 along with this work; if not, write to the Free Software Foundation,
 19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 20  *
 21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 22  * or visit www.oracle.com if you need additional information or have any

 52                 return "boolean[]";
 53             case 'C':
 54                 return "char[]";
 55             case 'S':
 56                 return "short[]";
 57             case 'I':
 58                 return "int[]";
 59             case 'F':
 60                 return "float[]";
 61             case 'J':
 62                 return "long[]";
 63             case 'D':
 64                 return "double[]";
 65             default:
 66                 throw new RuntimeException("invalid array element sig: " + sig);
 67         }
 68     }
 69 
 70     private static int elementSize(byte type) {
 71         switch (type) {
 72             case 'B':
 73             case 'Z':
 74                 return 1;
 75             case 'C':
 76             case 'S':
 77                 return 2;
 78             case 'I':
 79             case 'F':
 80                 return 4;
 81             case 'J':
 82             case 'D':
 83                 return 8;
 84             default:
 85                 throw new RuntimeException("invalid array element type: " + type);
 86         }
 87     }
 88 
 89     /*
 90      * Java primitive array record (HPROF_GC_PRIM_ARRAY_DUMP) looks
 91      * as below:
 92      *
 93      *    object ID
 94      *    stack trace serial number (int)
 95      *    number of elements (int)
 96      *    element type (byte)
 97      *    array data
 98      */
 99     @Override
100     protected final long readValueLength() throws IOException {
101         long offset = getOffset() + idSize() + 4;
102         // length of the array in elements
< prev index next >