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.cf.code.BootstrapMethodsList;
20 import com.android.dx.rop.cst.ConstantPool;
21 import com.android.dx.rop.cst.CstString;
22 import com.android.dx.rop.cst.CstType;
23 import com.android.dx.rop.type.TypeList;
24 
25 /**
26  * Interface for things which purport to be class files or reasonable
27  * facsimiles thereof.
28  *
29  * <p><b>Note:</b> The fields referred to in this documentation are of the
30  * {@code ClassFile} structure defined in vmspec-2 sec4.1.
31  */
32 public interface ClassFile extends HasAttribute {
33     /**
34      * Gets the field {@code magic}.
35      *
36      * @return the value in question
37      */
getMagic()38     public int getMagic();
39 
40     /**
41      * Gets the field {@code minor_version}.
42      *
43      * @return the value in question
44      */
getMinorVersion()45     public int getMinorVersion();
46 
47     /**
48      * Gets the field {@code major_version}.
49      *
50      * @return the value in question
51      */
getMajorVersion()52     public int getMajorVersion();
53 
54     /**
55      * Gets the field {@code access_flags}.
56      *
57      * @return the value in question
58      */
getAccessFlags()59     public int getAccessFlags();
60 
61     /**
62      * Gets the field {@code this_class}, interpreted as a type constant.
63      *
64      * @return {@code non-null;} the value in question
65      */
getThisClass()66     public CstType getThisClass();
67 
68     /**
69      * Gets the field {@code super_class}, interpreted as a type constant
70      * if non-zero.
71      *
72      * @return {@code null-ok;} the value in question
73      */
getSuperclass()74     public CstType getSuperclass();
75 
76     /**
77      * Gets the field {@code constant_pool} (along with
78      * {@code constant_pool_count}).
79      *
80      * @return {@code non-null;} the constant pool
81      */
getConstantPool()82     public ConstantPool getConstantPool();
83 
84     /**
85      * Gets the field {@code interfaces} (along with
86      * {@code interfaces_count}).
87      *
88      * @return {@code non-null;} the list of interfaces
89      */
getInterfaces()90     public TypeList getInterfaces();
91 
92     /**
93      * Gets the field {@code fields} (along with
94      * {@code fields_count}).
95      *
96      * @return {@code non-null;} the list of fields
97      */
getFields()98     public FieldList getFields();
99 
100     /**
101      * Gets the field {@code methods} (along with
102      * {@code methods_count}).
103      *
104      * @return {@code non-null;} the list of fields
105      */
getMethods()106     public MethodList getMethods();
107 
108     /**
109      * Gets the field {@code attributes} (along with
110      * {@code attributes_count}).
111      *
112      * @return {@code non-null;} the list of attributes
113      */
114     @Override
getAttributes()115     public AttributeList getAttributes();
116 
117     /**
118      * Gets the bootstrap method {@code attributes}.
119      * @return {@code non-null;} the list of bootstrap methods
120      */
getBootstrapMethods()121     public BootstrapMethodsList getBootstrapMethods();
122 
123     /**
124      * Gets the name out of the {@code SourceFile} attribute of this
125      * file, if any. This is a convenient shorthand for scrounging around
126      * the class's attributes.
127      *
128      * @return {@code non-null;} the constant pool
129      */
getSourceFile()130     public CstString getSourceFile();
131 }
132