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
17package com.android.dx.cf.iface;
18
19import com.android.dx.cf.code.BootstrapMethodsList;
20import com.android.dx.rop.cst.ConstantPool;
21import com.android.dx.rop.cst.CstString;
22import com.android.dx.rop.cst.CstType;
23import 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 */
32public interface ClassFile extends HasAttribute {
33    /**
34     * Gets the field {@code magic}.
35     *
36     * @return the value in question
37     */
38    public int getMagic();
39
40    /**
41     * Gets the field {@code minor_version}.
42     *
43     * @return the value in question
44     */
45    public int getMinorVersion();
46
47    /**
48     * Gets the field {@code major_version}.
49     *
50     * @return the value in question
51     */
52    public int getMajorVersion();
53
54    /**
55     * Gets the field {@code access_flags}.
56     *
57     * @return the value in question
58     */
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     */
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     */
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     */
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     */
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     */
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     */
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    public AttributeList getAttributes();
115
116    /**
117     * Gets the bootstrap method {@code attributes}.
118     * @return {@code non-null;} the list of bootstrap methods
119     */
120    public BootstrapMethodsList getBootstrapMethods();
121
122    /**
123     * Gets the name out of the {@code SourceFile} attribute of this
124     * file, if any. This is a convenient shorthand for scrounging around
125     * the class's attributes.
126     *
127     * @return {@code non-null;} the constant pool
128     */
129    public CstString getSourceFile();
130}
131