Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename ClassInfo.canonicalConstructor() to canonicalRecordConstructor() #421

Merged
merged 1 commit into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions core/src/main/java/org/jboss/jandex/ClassInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -757,13 +757,13 @@ public final List<MethodInfo> constructors() {
/**
* Returns the canonical constructor of this record. If this class is not a record, returns {@code null}.
* <p>
* Note that this method has the same limitations as {@link #unsortedRecordComponents()}. That is,
* at most 256 record components may be present, and an assumption is made that bytecode order
* of record components corresponds to the declaration order.
* Note that this method has the same limitations as {@link #recordComponentsInDeclarationOrder()}.
* That is, at most 256 record components may be present, and an assumption is made that bytecode
* order of record components corresponds to the declaration order.
*
* @return the canonical constructor of this record, or {@code null} if this class is not a record
*/
public MethodInfo canonicalConstructor() {
public MethodInfo canonicalRecordConstructor() {
if (!isRecord()) {
return null;
}
Expand Down Expand Up @@ -955,7 +955,7 @@ public final RecordComponentInfo recordComponent(String name) {
* If this class is not a record, returns an empty list.
* <p>
* Note that the result <em>doesn't</em> have any guaranteed order. If you need
* declaration order, use {@link #unsortedRecordComponents()}.
* declaration order, use {@link #recordComponentsInDeclarationOrder()}.
*
* @return immutable list of record components
*/
Expand Down
32 changes: 16 additions & 16 deletions core/src/test/java/org/jboss/jandex/test/RecordTestCase.java
Original file line number Diff line number Diff line change
Expand Up @@ -158,47 +158,47 @@ public void testRecordSignatureProcessed() {
public void canonicalCtor() {
ClassInfo rec = index.getClassByName("test.RecordWithNoComponentsAndDefaultCanonicalCtor");
assertEquals(1, rec.constructors().size());
assertEquals(rec.constructors().get(0), rec.canonicalConstructor());
assertEquals(rec.constructors().get(0), rec.canonicalRecordConstructor());

rec = index.getClassByName("test.RecordWithNoComponentsAndCompactCanonicalCtor");
assertEquals(1, rec.constructors().size());
assertEquals(rec.constructors().get(0), rec.canonicalConstructor());
assertEquals(rec.constructors().get(0), rec.canonicalRecordConstructor());

rec = index.getClassByName("test.RecordWithNoComponentsAndCustomCanonicalCtor");
assertEquals(1, rec.constructors().size());
assertEquals(rec.constructors().get(0), rec.canonicalConstructor());
assertEquals(rec.constructors().get(0), rec.canonicalRecordConstructor());

rec = index.getClassByName("test.RecordWithDefaultCanonicalCtor");
assertEquals(1, rec.constructors().size());
assertEquals(rec.constructors().get(0), rec.canonicalConstructor());
assertEquals(rec.constructors().get(0), rec.canonicalRecordConstructor());

rec = index.getClassByName("test.RecordWithCompactCanonicalCtor");
assertEquals(1, rec.constructors().size());
assertEquals(rec.constructors().get(0), rec.canonicalConstructor());
assertEquals(rec.constructors().get(0), rec.canonicalRecordConstructor());

rec = index.getClassByName("test.RecordWithCustomCanonicalCtor");
assertEquals(1, rec.constructors().size());
assertEquals(rec.constructors().get(0), rec.canonicalConstructor());
assertEquals(rec.constructors().get(0), rec.canonicalRecordConstructor());

rec = index.getClassByName("test.RecordWithMultipleCtorsAndDefaultCanonicalCtor");
assertEquals(4, rec.constructors().size());
assertEquals(2, rec.canonicalConstructor().parametersCount());
assertEquals(PrimitiveType.INT, rec.canonicalConstructor().parameterType(0));
assertEquals(ClassType.create(String.class), rec.canonicalConstructor().parameterType(1));
assertEquals(2, rec.canonicalRecordConstructor().parametersCount());
assertEquals(PrimitiveType.INT, rec.canonicalRecordConstructor().parameterType(0));
assertEquals(ClassType.create(String.class), rec.canonicalRecordConstructor().parameterType(1));

rec = index.getClassByName("test.RecordWithMultipleCtorsAndCompactCanonicalCtor");
assertEquals(4, rec.constructors().size());
assertEquals(2, rec.canonicalConstructor().parametersCount());
assertEquals(PrimitiveType.INT, rec.canonicalConstructor().parameterType(0));
assertEquals(ClassType.create(String.class), rec.canonicalConstructor().parameterType(1));
assertEquals(2, rec.canonicalRecordConstructor().parametersCount());
assertEquals(PrimitiveType.INT, rec.canonicalRecordConstructor().parameterType(0));
assertEquals(ClassType.create(String.class), rec.canonicalRecordConstructor().parameterType(1));

rec = index.getClassByName("test.RecordWithMultipleCtorsAndCustomCanonicalCtor");
assertEquals(4, rec.constructors().size());
assertEquals(2, rec.canonicalConstructor().parametersCount());
assertEquals(PrimitiveType.INT, rec.canonicalConstructor().parameterType(0));
assertEquals(ClassType.create(String.class), rec.canonicalConstructor().parameterType(1));
assertEquals(2, rec.canonicalRecordConstructor().parametersCount());
assertEquals(PrimitiveType.INT, rec.canonicalRecordConstructor().parameterType(0));
assertEquals(ClassType.create(String.class), rec.canonicalRecordConstructor().parameterType(1));

assertNull(index.getClassByName(RecordTestCase.class).canonicalConstructor());
assertNull(index.getClassByName(RecordTestCase.class).canonicalRecordConstructor());
}

private Index buildIndex() throws IOException {
Expand Down