Skip to content

SecurityManager is deprecated for removal #1636

Closed

Description

@netdpb

SecurityManager is deprecated for removal in JDK 24, but it's used in Native.getCallingClass(). That usage has to be removed in order for JNA to be compatible with newer versions of Java.

Activity

  1. cushon commented on Dec 3, 2024

    @cushon

    It's being used for SecurityManager#getClassContext. For Java 9 and newer, this could be migrated to use java.lang.StackWalker#getCallerClass instead, e.g.:

    StackWalker.getInstance(StackWalker.Option.RETAIN_CLASS_REFERENCE).getCallerClass()

    That would require some extra work to support earlier Java versions, but it could potentially use reflection to call that API on Java 9+, or use a Multi-Release jar.

  2. matthiasblaesing commented on Dec 3, 2024

    @matthiasblaesing
    Member

    Just to get some relaxation in here: The current JDK 24-EA happily lets you create a subclass of SecurityManager and call getClassContext on it. So world will not end when JDK24 is released.

    I think the relevant part is:

    We will leave a minimal version of the java.lang.SecurityManager class in place for compatibility with the few applications, libraries, and tools that still use it. We will remove this class in a future release.

  3. changed the title [-]SecurityManager is deprecated and will be removed in JDK 24[/-] [+]SecurityManager is deprecated for removal[/+] on Dec 4, 2024
  4. dblock commented on Dec 4, 2024

    @dblock
    Member

    A lot of relevant discussion here: opensearch-project/OpenSearch#1687

    OpenSearch uses JNA and JSM extensively, cc: @reta.

  5. reta commented on Dec 5, 2024

    @reta

    OpenSearch uses JNA and JSM extensively, cc: @reta.

    Thanks @dblock , java.lang.StackWalker is what we are looking for to get the caller (but OS has JDK-11 baseline, so no need to fallback to MH / reflection)

  6. added a commit that references this issue on Dec 8, 2024
    2277556
  7. matthiasblaesing commented on Dec 8, 2024

    @matthiasblaesing
    Member

    If anyone is interested, PR #1638 is available with a MH based approach to replace SecurityManager and AccessController.

  8. added a commit that references this issue on Dec 12, 2024
    69955bd
  9. added 2 commits that reference this issue on Jul 15, 2025
    f6b09c3
    9b5e1ad
  10. added 2 commits that reference this issue on May 10, 2026
    e2c1f02
    f5f17d5
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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions