Skip to content

JniTypeSignature uses CultureInfo #335

@jonpryor

Description

@jonpryor

(This might be an effectively meaningless optimization; presumably someone is going to initialize CultureInfo during process startup. It just so happens that in a profiler run, JniTypeSignature was the first one, hence this bug...)

The JniTypeSignature(string) constructor uses string.Contains(): https://github.com/xamarin/java.interop/blob/8ad8e1205a29b22f4b353fa3f760e5f9959712a7/src/Java.Interop/Java.Interop/JniTypeSignature.cs#L42

On Mono (and .NET?), string.Contains() delegates to CultureInfo, which requires loading and initializing the entire CultureInfo infrastructure (if it hasn't already been loaded & initialized).

As this is hitting Xamarin.Android process startup, and should be straightforward to avoid, we should fix JniTypeSignature to avoid Culture-aware string comparisons, especially as we don't need culture-aware string comparisons.

(Note: using StringComparison.Ordinal* still hits CultureInfo; it just uses CultureInfo.InvariantCulture.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementProposed change to current functionalityjava-interopRuntime bridge between .NET and Java

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions