Skip to content

Commit

Permalink
8332597: Remove redundant methods from j.l.classfile.ClassReader API
Browse files Browse the repository at this point in the history
  • Loading branch information
asotona committed May 21, 2024
1 parent 7ffc999 commit 20838db
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 26 deletions.
13 changes: 0 additions & 13 deletions src/java.base/share/classes/java/lang/classfile/ClassReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,22 +71,9 @@ public sealed interface ClassReader extends ConstantPool
/** {@return the constant pool entry describing the name of the superclass, if any} */
Optional<ClassEntry> superclassEntry();

/** {@return the offset into the classfile of the {@code this_class} field} */
int thisClassPos();

/** {@return the length of the classfile, in bytes} */
int classfileLength();

// Buffer related

/**
* {@return the offset following the block of attributes starting at the
* specified position}
* @param offset the offset into the classfile at which the attribute block
* starts
*/
int skipAttributeHolder(int offset);

// Constant pool

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ public abstract sealed class BoundAttribute<T extends Attribute<T>>

static final int NAME_AND_LENGTH_PREFIX = 6;
private final AttributeMapper<T> mapper;
final ClassReader classReader;
final ClassReaderImpl classReader;
final int payloadStart;

BoundAttribute(ClassReader classReader, AttributeMapper<T> mapper, int payloadStart) {
this.mapper = mapper;
this.classReader = classReader;
this.classReader = (ClassReaderImpl)classReader;
this.payloadStart = payloadStart;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,12 @@
*/
package jdk.internal.classfile.impl;

import java.util.Collection;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.function.Consumer;
import java.util.stream.Collectors;

import java.lang.classfile.ClassBuilder;
import java.lang.classfile.constantpool.ClassEntry;
import java.lang.reflect.AccessFlag;
import java.lang.classfile.AccessFlags;
Expand All @@ -40,12 +38,9 @@
import java.lang.classfile.Attributes;
import java.lang.classfile.ClassElement;
import java.lang.classfile.ClassModel;
import java.lang.classfile.ClassReader;
import java.lang.classfile.ClassTransform;
import java.lang.classfile.ClassFile;
import java.lang.classfile.ClassFileVersion;
import java.lang.classfile.constantpool.ConstantPool;
import java.lang.classfile.constantpool.ConstantPoolBuilder;
import java.lang.classfile.FieldModel;
import java.lang.classfile.Interfaces;
import java.lang.classfile.MethodModel;
Expand All @@ -56,7 +51,7 @@ public final class ClassImpl
extends AbstractElement
implements ClassModel {

final ClassReader reader;
final ClassReaderImpl reader;
private final int attributesPos;
private final List<MethodModel> methods;
private final List<FieldModel> fields;
Expand All @@ -65,7 +60,6 @@ public final class ClassImpl

public ClassImpl(byte[] cfbytes, ClassFileImpl context) {
this.reader = new ClassReaderImpl(cfbytes, context);
ClassReaderImpl reader = (ClassReaderImpl) this.reader;
int p = reader.interfacesPos;
int icnt = reader.readU2(p);
p += 2 + icnt * 2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@ public Optional<ClassEntry> superclassEntry() {
return superclass;
}

@Override
public int thisClassPos() {
return thisClassPos;
}
Expand Down Expand Up @@ -397,7 +396,6 @@ public AbstractPoolEntry.Utf8EntryImpl utf8EntryByIndex(int index) {
throw new ConstantPoolException("Not a UTF8 - index: " + index);
}

@Override
public int skipAttributeHolder(int offset) {
int p = offset;
int cnt = readU2(p);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ private void inflateMetadata() {
if (!inflated) {
if (labels == null)
labels = new LabelImpl[codeLength + 1];
if (((ClassReaderImpl)classReader).context().lineNumbersOption() == ClassFile.LineNumbersOption.PASS_LINE_NUMBERS)
if (classReader.context().lineNumbersOption() == ClassFile.LineNumbersOption.PASS_LINE_NUMBERS)
inflateLineNumbers();
inflateJumpTargets();
inflateTypeAnnotations();
Expand Down Expand Up @@ -170,7 +170,7 @@ public void forEachElement(Consumer<CodeElement> consumer) {
inflateMetadata();
boolean doLineNumbers = (lineNumbers != null);
generateCatchTargets(consumer);
if (((ClassReaderImpl)classReader).context().debugElementsOption() == ClassFile.DebugElementsOption.PASS_DEBUG)
if (classReader.context().debugElementsOption() == ClassFile.DebugElementsOption.PASS_DEBUG)
generateDebugElements(consumer);
for (int pos=codeStart; pos<codeEnd; ) {
if (labels[pos - codeStart] != null)
Expand Down

0 comments on commit 20838db

Please sign in to comment.