Path: blob/master/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/SignatureConverter.java
62930 views
/*1* Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324package sun.jvm.hotspot.runtime;2526import sun.jvm.hotspot.oops.*;2728public class SignatureConverter extends SignatureIterator {29private StringBuffer buf;30private boolean first = true;3132public SignatureConverter(Symbol sig, StringBuffer buf) {33super(sig);34this.buf = buf;35}3637public void doBool () { appendComma(); buf.append("boolean"); }38public void doChar () { appendComma(); buf.append("char"); }39public void doFloat () { appendComma(); buf.append("float"); }40public void doDouble() { appendComma(); buf.append("double"); }41public void doByte () { appendComma(); buf.append("byte"); }42public void doShort () { appendComma(); buf.append("short"); }43public void doInt () { appendComma(); buf.append("int"); }44public void doLong () { appendComma(); buf.append("long"); }45public void doVoid () {46if(isReturnType()) {47appendComma(); buf.append("void");48} else {49throw new RuntimeException("Should not reach here");50}51}5253public void doObject(int begin, int end) { doObject(begin, end, true); }54public void doArray (int begin, int end) {55appendComma();56int inner = arrayInnerBegin(begin);57switch (_signature.getByteAt(inner)) {58case 'B': buf.append("byte"); break;59case 'C': buf.append("char"); break;60case 'D': buf.append("double"); break;61case 'F': buf.append("float"); break;62case 'I': buf.append("int"); break;63case 'J': buf.append("long"); break;64case 'S': buf.append("short"); break;65case 'Z': buf.append("boolean"); break;66case 'L': doObject(inner + 1, end, false); break;67default: break;68}69for (int i = 0; i < inner - begin + 1; i++) {70buf.append("[]");71}72}7374public void appendComma() {75if (!first) {76buf.append(", ");77}78first = false;79}8081private void doObject(int begin, int end, boolean comma) {82if (comma) {83appendComma();84}85appendSubstring(begin, end - 1);86}8788private void appendSubstring(int begin, int end) {89for (int i = begin; i < end; i++) {90buf.append((char) (_signature.getByteAt(i) & 0xFF));91}92}9394private int arrayInnerBegin(int begin) {95while (_signature.getByteAt(begin) == '[') {96++begin;97}98return begin;99}100}101102103