Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: d53fc980b7ab86ea32953e56972f12ffb0a4e403 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/*******************************************************************************
 * Copyright (c) 2009, 2010 IBM Corporation and others.
 *
 * This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License 2.0
 * which accompanies this distribution, and is available at
 * https://www.eclipse.org/legal/epl-2.0/
 *
 * SPDX-License-Identifier: EPL-2.0
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.equinox.p2.internal.repository.comparator.java;

public class InnerClassesAttributeEntry extends ClassFileStruct {

	private int innerClassNameIndex;
	private int outerClassNameIndex;
	private int innerNameIndex;
	private char[] innerClassName;
	private char[] outerClassName;
	private char[] innerName;
	private int accessFlags;

	public InnerClassesAttributeEntry(byte classFileBytes[], ConstantPool constantPool, int offset) throws ClassFormatException {
		this.innerClassNameIndex = u2At(classFileBytes, 0, offset);
		this.outerClassNameIndex = u2At(classFileBytes, 2, offset);
		this.innerNameIndex = u2At(classFileBytes, 4, offset);
		this.accessFlags = u2At(classFileBytes, 6, offset);
		ConstantPoolEntry constantPoolEntry;
		if (this.innerClassNameIndex != 0) {
			constantPoolEntry = constantPool.decodeEntry(this.innerClassNameIndex);
			if (constantPoolEntry.getKind() != ConstantPoolConstant.CONSTANT_Class) {
				throw new ClassFormatException(ClassFormatException.INVALID_CONSTANT_POOL_ENTRY);
			}
			this.innerClassName = constantPoolEntry.getClassInfoName();
		}
		if (this.outerClassNameIndex != 0) {
			constantPoolEntry = constantPool.decodeEntry(this.outerClassNameIndex);
			if (constantPoolEntry.getKind() != ConstantPoolConstant.CONSTANT_Class) {
				throw new ClassFormatException(ClassFormatException.INVALID_CONSTANT_POOL_ENTRY);
			}
			this.outerClassName = constantPoolEntry.getClassInfoName();
		}
		if (this.innerNameIndex != 0) {
			constantPoolEntry = constantPool.decodeEntry(this.innerNameIndex);
			if (constantPoolEntry.getKind() != ConstantPoolConstant.CONSTANT_Utf8) {
				throw new ClassFormatException(ClassFormatException.INVALID_CONSTANT_POOL_ENTRY);
			}
			this.innerName = constantPoolEntry.getUtf8Value();
		}
	}

	/*
	 * @see IInnerClassesAttributeEntry#getAccessFlags()
	 */
	public int getAccessFlags() {
		return this.accessFlags;
	}

	/*
	 * @see IInnerClassesAttributeEntry#getInnerClassName()
	 */
	public char[] getInnerClassName() {
		return this.innerClassName;
	}

	/*
	 * @see IInnerClassesAttributeEntry#getInnerClassNameIndex()
	 */
	public int getInnerClassNameIndex() {
		return this.innerClassNameIndex;
	}

	/*
	 * @see IInnerClassesAttributeEntry#getInnerName()
	 */
	public char[] getInnerName() {
		return this.innerName;
	}

	/*
	 * @see IInnerClassesAttributeEntry#getInnerNameIndex()
	 */
	public int getInnerNameIndex() {
		return this.innerNameIndex;
	}

	/*
	 * @see IInnerClassesAttributeEntry#getOuterClassName()
	 */
	public char[] getOuterClassName() {
		return this.outerClassName;
	}

	/*
	 * @see IInnerClassesAttributeEntry#getOuterClassNameIndex()
	 */
	public int getOuterClassNameIndex() {
		return this.outerClassNameIndex;
	}
}

Back to the top