mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-26 22:34:27 +02:00
8332597: Remove redundant methods from j.l.classfile.ClassReader API
Reviewed-by: liach, jlahoda
This commit is contained in:
parent
57bfd0e393
commit
579cf705ff
5 changed files with 6 additions and 23 deletions
|
@ -71,22 +71,9 @@ public sealed interface ClassReader extends ConstantPool
|
||||||
/** {@return the constant pool entry describing the name of the superclass, if any} */
|
/** {@return the constant pool entry describing the name of the superclass, if any} */
|
||||||
Optional<ClassEntry> superclassEntry();
|
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} */
|
/** {@return the length of the classfile, in bytes} */
|
||||||
int classfileLength();
|
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
|
// Constant pool
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -51,12 +51,12 @@ public abstract sealed class BoundAttribute<T extends Attribute<T>>
|
||||||
|
|
||||||
static final int NAME_AND_LENGTH_PREFIX = 6;
|
static final int NAME_AND_LENGTH_PREFIX = 6;
|
||||||
private final AttributeMapper<T> mapper;
|
private final AttributeMapper<T> mapper;
|
||||||
final ClassReader classReader;
|
final ClassReaderImpl classReader;
|
||||||
final int payloadStart;
|
final int payloadStart;
|
||||||
|
|
||||||
BoundAttribute(ClassReader classReader, AttributeMapper<T> mapper, int payloadStart) {
|
BoundAttribute(ClassReader classReader, AttributeMapper<T> mapper, int payloadStart) {
|
||||||
this.mapper = mapper;
|
this.mapper = mapper;
|
||||||
this.classReader = classReader;
|
this.classReader = (ClassReaderImpl)classReader;
|
||||||
this.payloadStart = payloadStart;
|
this.payloadStart = payloadStart;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -34,7 +34,6 @@ import java.lang.classfile.Attribute;
|
||||||
import java.lang.classfile.Attributes;
|
import java.lang.classfile.Attributes;
|
||||||
import java.lang.classfile.ClassElement;
|
import java.lang.classfile.ClassElement;
|
||||||
import java.lang.classfile.ClassModel;
|
import java.lang.classfile.ClassModel;
|
||||||
import java.lang.classfile.ClassReader;
|
|
||||||
import java.lang.classfile.ClassFile;
|
import java.lang.classfile.ClassFile;
|
||||||
import java.lang.classfile.ClassFileVersion;
|
import java.lang.classfile.ClassFileVersion;
|
||||||
import java.lang.classfile.CustomAttribute;
|
import java.lang.classfile.CustomAttribute;
|
||||||
|
@ -60,7 +59,7 @@ public final class ClassImpl
|
||||||
extends AbstractElement
|
extends AbstractElement
|
||||||
implements ClassModel {
|
implements ClassModel {
|
||||||
|
|
||||||
final ClassReader reader;
|
final ClassReaderImpl reader;
|
||||||
private final int attributesPos;
|
private final int attributesPos;
|
||||||
private final List<MethodModel> methods;
|
private final List<MethodModel> methods;
|
||||||
private final List<FieldModel> fields;
|
private final List<FieldModel> fields;
|
||||||
|
@ -69,7 +68,6 @@ public final class ClassImpl
|
||||||
|
|
||||||
public ClassImpl(byte[] cfbytes, ClassFileImpl context) {
|
public ClassImpl(byte[] cfbytes, ClassFileImpl context) {
|
||||||
this.reader = new ClassReaderImpl(cfbytes, context);
|
this.reader = new ClassReaderImpl(cfbytes, context);
|
||||||
ClassReaderImpl reader = (ClassReaderImpl) this.reader;
|
|
||||||
int p = reader.interfacesPos;
|
int p = reader.interfacesPos;
|
||||||
int icnt = reader.readU2(p);
|
int icnt = reader.readU2(p);
|
||||||
p += 2 + icnt * 2;
|
p += 2 + icnt * 2;
|
||||||
|
|
|
@ -164,7 +164,6 @@ public final class ClassReaderImpl
|
||||||
return superclass;
|
return superclass;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int thisClassPos() {
|
public int thisClassPos() {
|
||||||
return thisClassPos;
|
return thisClassPos;
|
||||||
}
|
}
|
||||||
|
@ -397,7 +396,6 @@ public final class ClassReaderImpl
|
||||||
throw new ConstantPoolException("Not a UTF8 - index: " + index);
|
throw new ConstantPoolException("Not a UTF8 - index: " + index);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int skipAttributeHolder(int offset) {
|
public int skipAttributeHolder(int offset) {
|
||||||
int p = offset;
|
int p = offset;
|
||||||
int cnt = readU2(p);
|
int cnt = readU2(p);
|
||||||
|
|
|
@ -121,7 +121,7 @@ public final class CodeImpl
|
||||||
if (!inflated) {
|
if (!inflated) {
|
||||||
if (labels == null)
|
if (labels == null)
|
||||||
labels = new LabelImpl[codeLength + 1];
|
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();
|
inflateLineNumbers();
|
||||||
inflateJumpTargets();
|
inflateJumpTargets();
|
||||||
inflateTypeAnnotations();
|
inflateTypeAnnotations();
|
||||||
|
@ -170,7 +170,7 @@ public final class CodeImpl
|
||||||
inflateMetadata();
|
inflateMetadata();
|
||||||
boolean doLineNumbers = (lineNumbers != null);
|
boolean doLineNumbers = (lineNumbers != null);
|
||||||
generateCatchTargets(consumer);
|
generateCatchTargets(consumer);
|
||||||
if (((ClassReaderImpl)classReader).context().debugElementsOption() == ClassFile.DebugElementsOption.PASS_DEBUG)
|
if (classReader.context().debugElementsOption() == ClassFile.DebugElementsOption.PASS_DEBUG)
|
||||||
generateDebugElements(consumer);
|
generateDebugElements(consumer);
|
||||||
for (int pos=codeStart; pos<codeEnd; ) {
|
for (int pos=codeStart; pos<codeEnd; ) {
|
||||||
if (labels[pos - codeStart] != null)
|
if (labels[pos - codeStart] != null)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue