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
Reviewed-by: liach, jlahoda
  • Loading branch information
asotona committed May 30, 2024
1 parent 57bfd0e commit 579cf70
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 23 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 @@ -51,12 +51,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
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -34,7 +34,6 @@
import java.lang.classfile.Attributes;
import java.lang.classfile.ClassElement;
import java.lang.classfile.ClassModel;
import java.lang.classfile.ClassReader;
import java.lang.classfile.ClassFile;
import java.lang.classfile.ClassFileVersion;
import java.lang.classfile.CustomAttribute;
Expand All @@ -60,7 +59,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 @@ -69,7 +68,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

1 comment on commit 579cf70

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.