Skip to content
This repository was archived by the owner on Nov 9, 2026. It is now read-only.
This repository was archived by the owner on Nov 9, 2026. It is now read-only.

JniTypeSignature uses CultureInfo #335

Closed

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.)

Activity

  1. added
    enhancement
    java-interop
    on Apr 16, 2020
  2. locked and limited conversation to collaborators on Apr 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementjava-interop

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions