1 /* 2 * Copyright (C) 2007 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.dx.cf.iface; 18 19 import com.android.dx.rop.code.AccessFlags; 20 import com.android.dx.rop.cst.CstNat; 21 import com.android.dx.rop.cst.CstType; 22 import com.android.dx.rop.type.Prototype; 23 24 /** 25 * Standard implementation of {@link Method}, which directly stores 26 * all the associated data. 27 */ 28 public final class StdMethod extends StdMember implements Method { 29 /** non-null; the effective method descriptor */ 30 private final Prototype effectiveDescriptor; 31 32 /** 33 * Constructs an instance. 34 * 35 * @param definingClass non-null; the defining class 36 * @param accessFlags access flags 37 * @param nat non-null; member name and type (descriptor) 38 * @param attributes non-null; list of associated attributes 39 */ StdMethod(CstType definingClass, int accessFlags, CstNat nat, AttributeList attributes)40 public StdMethod(CstType definingClass, int accessFlags, CstNat nat, 41 AttributeList attributes) { 42 super(definingClass, accessFlags, nat, attributes); 43 44 String descStr = getDescriptor().getString(); 45 effectiveDescriptor = 46 Prototype.intern(descStr, definingClass.getClassType(), 47 AccessFlags.isStatic(accessFlags), 48 nat.isInstanceInit()); 49 } 50 51 /** {@inheritDoc} */ getEffectiveDescriptor()52 public Prototype getEffectiveDescriptor() { 53 return effectiveDescriptor; 54 } 55 } 56