diff options
author | 2023-03-21 18:40:45 +0000 | |
---|---|---|
committer | 2023-04-04 11:12:03 +0000 | |
commit | d8e3d112ea678abe3d8005fadff0b5b49fae591d (patch) | |
tree | f4e29028c7d29f655426817eda58b87bcdc0d398 /runtime/class_linker.cc | |
parent | bd10861f33fcc1a1e7ddae3c48eb452a398e74a4 (diff) |
Use @Record annotation to implement the record type
Bug: 272698028
Test: atest CtsLibcoreTestCases:crossvmtest
Change-Id: Ia7a7ff66634b3fae40b029ee51d5e6bf8513a461
Diffstat (limited to 'runtime/class_linker.cc')
-rw-r--r-- | runtime/class_linker.cc | 27 |
1 files changed, 2 insertions, 25 deletions
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc index cdd07f6e40..682f358d89 100644 --- a/runtime/class_linker.cc +++ b/runtime/class_linker.cc @@ -9382,31 +9382,8 @@ void ClassLinker::SetRecordClassFlagIfNeeded(Handle<mirror::Class> klass) { } } - // Record class should have record attributes specifying various things, - // including component type, name and the order of record components. The dexer - // should emit @dalvik.annotation.Record annotation. But before the annotation is - // emitted correctly b/272698028, we workaround by reading @MethodParameters annotation - // as a temporary replacement. - uint32_t num_of_fields = klass->NumInstanceFields(); - for (ArtMethod& method : klass->GetDirectMethods(image_pointer_size_)) { - // JLS 8.10.2 Record body can't declare instance fields. - // JLS 8.10.4 Record class has only one canonical constructor. - // Dexer should emit @MethodParameters method annotation along with - // the canonical constructor. - if (method.IsConstructor() && method.GetNumberOfParameters() == num_of_fields) { - if (num_of_fields == 0 || - annotations::IsMethodAnnotationPresent( - &method, "Ldalvik/annotation/MethodParameters;", DexFile::kDexVisibilitySystem)) { - // JLS 8.10.4 / 8.10.4.1 We should check if the constructor - // doesn't invoke other constructor in this class or invoke the super - // class constructor to confirm that it's the canonical constructor. - - // But it's good enough until @dalvik.annotation.Record is emitted - // from the dexer. - klass->SetRecordClass(); - return; - } - } + if (annotations::IsRecordClassAnnotationPresent(klass)) { + klass->SetRecordClass(); } } |