• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2011 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.dex;
18 
19 public final class ClassData {
20     private final Field[] staticFields;
21     private final Field[] instanceFields;
22     private final Method[] directMethods;
23     private final Method[] virtualMethods;
24 
ClassData(Field[] staticFields, Field[] instanceFields, Method[] directMethods, Method[] virtualMethods)25     public ClassData(Field[] staticFields, Field[] instanceFields,
26             Method[] directMethods, Method[] virtualMethods) {
27         this.staticFields = staticFields;
28         this.instanceFields = instanceFields;
29         this.directMethods = directMethods;
30         this.virtualMethods = virtualMethods;
31     }
32 
getStaticFields()33     public Field[] getStaticFields() {
34         return staticFields;
35     }
36 
getInstanceFields()37     public Field[] getInstanceFields() {
38         return instanceFields;
39     }
40 
getDirectMethods()41     public Method[] getDirectMethods() {
42         return directMethods;
43     }
44 
getVirtualMethods()45     public Method[] getVirtualMethods() {
46         return virtualMethods;
47     }
48 
allFields()49     public Field[] allFields() {
50         Field[] result = new Field[staticFields.length + instanceFields.length];
51         System.arraycopy(staticFields, 0, result, 0, staticFields.length);
52         System.arraycopy(instanceFields, 0, result, staticFields.length, instanceFields.length);
53         return result;
54     }
55 
allMethods()56     public Method[] allMethods() {
57         Method[] result = new Method[directMethods.length + virtualMethods.length];
58         System.arraycopy(directMethods, 0, result, 0, directMethods.length);
59         System.arraycopy(virtualMethods, 0, result, directMethods.length, virtualMethods.length);
60         return result;
61     }
62 
63     public static class Field {
64         private final int fieldIndex;
65         private final int accessFlags;
66 
Field(int fieldIndex, int accessFlags)67         public Field(int fieldIndex, int accessFlags) {
68             this.fieldIndex = fieldIndex;
69             this.accessFlags = accessFlags;
70         }
71 
getFieldIndex()72         public int getFieldIndex() {
73             return fieldIndex;
74         }
75 
getAccessFlags()76         public int getAccessFlags() {
77             return accessFlags;
78         }
79     }
80 
81     public static class Method {
82         private final int methodIndex;
83         private final int accessFlags;
84         private final int codeOffset;
85 
Method(int methodIndex, int accessFlags, int codeOffset)86         public Method(int methodIndex, int accessFlags, int codeOffset) {
87             this.methodIndex = methodIndex;
88             this.accessFlags = accessFlags;
89             this.codeOffset = codeOffset;
90         }
91 
getMethodIndex()92         public int getMethodIndex() {
93             return methodIndex;
94         }
95 
getAccessFlags()96         public int getAccessFlags() {
97             return accessFlags;
98         }
99 
getCodeOffset()100         public int getCodeOffset() {
101             return codeOffset;
102         }
103     }
104 }
105