Skip to content

Commit afae4fd

Browse files
committed
[WIP] Fix order of ApplicationConfig fields
1 parent b5e434d commit afae4fd

File tree

3 files changed

+31
-12
lines changed

3 files changed

+31
-12
lines changed

src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Utilities/EnvironmentHelper.cs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public sealed class ApplicationConfig
4545
public bool uses_assembly_preload;
4646
public bool is_a_bundled_app;
4747
public bool broken_exception_transitions;
48-
public bool instant_run_enabled;
48+
public bool instant_run_enabled ;
4949
public bool jni_add_native_method_registration_attribute_present;
5050
public bool have_runtime_config_blob;
5151
public bool have_assemblies_blob;
@@ -60,11 +60,12 @@ public sealed class ApplicationConfig
6060
public uint android_runtime_jnienv_class_token;
6161
public uint jnienv_initialize_method_token;
6262
public uint jnienv_registerjninatives_method_token;
63-
public uint mono_components_mask;
6463
public uint mam_replacement_type_count;
6564
public uint mam_replacement_method_index_entry_count;
66-
public string android_package_name;
67-
};
65+
public uint mono_components_mask;
66+
public string android_package_name = String.Empty;
67+
}
68+
6869
const uint ApplicationConfigFieldCount = 25;
6970

7071
const string ApplicationConfigSymbolName = "application_config";
@@ -309,19 +310,19 @@ static ApplicationConfig ReadApplicationConfig (EnvironmentFile envFile)
309310
ret.number_of_dso_cache_entries = ConvertFieldToUInt32 ("jnienv_registerjninatives_method_token", envFile.Path, parser.SourceFilePath, item.LineNumber, field [1]);
310311
break;
311312

312-
case 21: // mono_components_mask: uint32_t / .word | .long
313+
case 21: // mam_replacement_type_count: uint32_t / .word | .long
313314
Assert.IsTrue (expectedUInt32Types.Contains (field [0]), $"Unexpected uint32_t field type in '{envFile.Path}:{item.LineNumber}': {field [0]}");
314-
ret.mono_components_mask = ConvertFieldToUInt32 ("mono_components_mask", envFile.Path, parser.SourceFilePath, item.LineNumber, field [1]);
315+
ret.mam_replacement_type_count = ConvertFieldToUInt32 ("mam_replacement_type_count", envFile.Path, parser.SourceFilePath, item.LineNumber, field [1]);
315316
break;
316317

317-
case 22: // mam_replacement_type_count: uint32_t / .word | .long
318+
case 22: // mam_replacement_method_index_entry_count: uint32_t / .word | .long
318319
Assert.IsTrue (expectedUInt32Types.Contains (field [0]), $"Unexpected uint32_t field type in '{envFile.Path}:{item.LineNumber}': {field [0]}");
319-
ret.mam_replacement_type_count = ConvertFieldToUInt32 ("mam_replacement_type_count", envFile.Path, parser.SourceFilePath, item.LineNumber, field [1]);
320+
ret.mam_replacement_method_index_entry_count = ConvertFieldToUInt32 ("mam_replacement_method_index_entry_count", envFile.Path, parser.SourceFilePath, item.LineNumber, field [1]);
320321
break;
321322

322-
case 23: // mam_replacement_method_index_entry_count: uint32_t / .word | .long
323+
case 23: // mono_components_mask: uint32_t / .word | .long
323324
Assert.IsTrue (expectedUInt32Types.Contains (field [0]), $"Unexpected uint32_t field type in '{envFile.Path}:{item.LineNumber}': {field [0]}");
324-
ret.mam_replacement_method_index_entry_count = ConvertFieldToUInt32 ("mam_replacement_method_index_entry_count", envFile.Path, parser.SourceFilePath, item.LineNumber, field [1]);
325+
ret.mono_components_mask = ConvertFieldToUInt32 ("mono_components_mask", envFile.Path, parser.SourceFilePath, item.LineNumber, field [1]);
325326
break;
326327

327328
case 24: // android_package_name: string / [pointer type]

src/Xamarin.Android.Build.Tasks/Utilities/ApplicationConfig.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ sealed class ApplicationConfig
4545
public uint android_runtime_jnienv_class_token;
4646
public uint jnienv_initialize_method_token;
4747
public uint jnienv_registerjninatives_method_token;
48-
public uint mono_components_mask;
4948
public uint mam_replacement_type_count;
5049
public uint mam_replacement_method_index_entry_count;
50+
public uint mono_components_mask;
5151
public string android_package_name = String.Empty;
5252
}
5353
}

src/monodroid/jni/mam-remapping.cc

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,28 @@ using namespace xamarin::android::internal;
99
force_inline bool
1010
MamRemapping::equal (MAMString const& left, const char *right, size_t right_len) noexcept
1111
{
12+
log_warn (LOG_DEFAULT, __PRETTY_FUNCTION__);
13+
log_warn (LOG_DEFAULT, " left.str == %s; left.length == %u", left.str, left.length);
14+
log_warn (LOG_DEFAULT, " right.str == %s; right.length == %zu", right, right_len);
1215
if (left.length != static_cast<uint32_t>(right_len) || left.str[0] != *right) {
16+
log_warn (LOG_DEFAULT, " #0");
1317
return false;
1418
}
1519

1620
if (memcmp (left.str, right, right_len) == 0) {
21+
log_warn (LOG_DEFAULT, " #1");
1722
return true;
1823
}
1924

25+
log_warn (LOG_DEFAULT, " #3");
2026
return false;
2127
}
2228

2329
const char*
2430
MamRemapping::lookup_replacement_type (const char *jniSimpleReference) noexcept
2531
{
32+
log_warn (LOG_DEFAULT, __PRETTY_FUNCTION__);
33+
log_warn (LOG_DEFAULT, " jniSimpleReference == %s", jniSimpleReference);
2634
if (application_config.mam_replacement_type_count == 0 || jniSimpleReference == nullptr || *jniSimpleReference == '\0') {
2735
return nullptr;
2836
}
@@ -43,19 +51,26 @@ MamRemapping::lookup_replacement_type (const char *jniSimpleReference) noexcept
4351
const MAMReplacementMethod*
4452
MamRemapping::lookup_replacement_method_info (const char *jniSourceType, const char *jniMethodName, const char *jniMethodSignature) noexcept
4553
{
54+
log_warn (LOG_DEFAULT, __PRETTY_FUNCTION__);
55+
log_warn (LOG_DEFAULT, " jniSourceType == %s; jniMethodName == %s; jniMethodSignature == %s", jniSourceType, jniMethodName, jniMethodSignature);
4656
if (application_config.mam_replacement_method_index_entry_count == 0 ||
4757
jniSourceType == nullptr || *jniSourceType == '\0' ||
4858
jniMethodName == nullptr || *jniMethodName == '\0') {
59+
log_warn (LOG_DEFAULT, " #0");
4960
return nullptr;
5061
}
5162

5263
size_t source_type_len = strlen (jniSourceType);
5364

65+
log_warn (LOG_DEFAULT, " application_config.mam_replacement_method_index_entry_count == %u", application_config.mam_replacement_method_index_entry_count);
5466
const MAMIndexTypeEntry *type = nullptr;
5567
for (size_t i = 0; i < application_config.mam_replacement_method_index_entry_count; i++) {
68+
log_warn (LOG_DEFAULT, " i == %zu", i);
5669
MAMIndexTypeEntry const& entry = mam_method_replacement_index[i];
70+
log_warn (LOG_DEFAULT, " mam_method_replacement_index[%zu].name.str == %s", i, mam_method_replacement_index[i].name.str);
5771

58-
if (!equal (entry.name, jniSourceType, source_type_len) != 0) {
72+
if (!equal (entry.name, jniSourceType, source_type_len)) {
73+
log_warn (LOG_DEFAULT, " -> cont");
5974
continue;
6075
}
6176

@@ -64,6 +79,7 @@ MamRemapping::lookup_replacement_method_info (const char *jniSourceType, const c
6479
}
6580

6681
if (type == nullptr || type->method_count == 0 || type->methods == nullptr) {
82+
log_warn (LOG_DEFAULT, " #1");
6783
return nullptr;
6884
}
6985

@@ -78,9 +94,11 @@ MamRemapping::lookup_replacement_method_info (const char *jniSourceType, const c
7894
}
7995

8096
if (entry.signature.length == 0 || equal (entry.signature, jniMethodSignature, signature_len)) {
97+
log_warn (LOG_DEFAULT, " #2");
8198
return &type->methods[i].replacement;
8299
}
83100
}
84101

102+
log_warn (LOG_DEFAULT, " #3");
85103
return nullptr;
86104
}

0 commit comments

Comments
 (0)