Here you can find the source of sizeOf(String typeDescriptor)
Parameter | Description |
---|---|
typeDescriptor | the descriptor for a single type, may be primitive. For example: I, J, Z, Ljava/lang/String; |
public static int sizeOf(String typeDescriptor)
//package com.java2s; /*//www . java2 s.co m * Copyright 2010-2012 VMware and contributors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ public class Main { /** * Return the size of a type. The size is usually 1 except for double and long which are of size 2. The descriptor * passed in is the full descriptor, including any leading 'L' and trailing ';'. * * @param typeDescriptor the descriptor for a single type, may be primitive. For example: I, J, Z, * Ljava/lang/String; * @return the size of the descriptor (number of slots it will consume), either 1 or 2 */ public static int sizeOf(String typeDescriptor) { if (typeDescriptor.length() != 1) { return 1; } char ch = typeDescriptor.charAt(0); if (ch == 'J' || ch == 'D') { return 2; } else { return 1; } } }