JDK-8272608 : java_lang_System::allow_security_manager() doesn't set its initialization flag
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 17,18
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2021-08-18
  • Updated: 2022-12-09
  • Resolved: 2021-09-10
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 17 JDK 18
17.0.6Fixed 18 b15Fixed
Related Reports
Relates :  
Description
javaClasses.cpp:

bool java_lang_System::allow_security_manager() {
  static int initialized = false;
  static bool allowed = true; // default
  if (!initialized) {
    oop base = vmClasses::System_klass()->static_field_base_raw();
    int never = base->int_field(_static_never_offset);
    allowed = (base->int_field(_static_allow_security_offset) != never);
  }
  return allowed;
}

We never set `initialized` to true, so every call to allow_security_manager() re-reads the System class field.
Comments
A pull request was submitted for review. URL: https://git.openjdk.org/jdk17u-dev/pull/843 Date: 2022-10-26 11:34:38 +0000
26-10-2022

Fix Request (17u) Fixes a minor performance bug. Applies cleanly. Testing passes.
26-10-2022

Worth picking up to 17u as the followup for JDK-8195744?
06-10-2021

Changeset: 08f0be83 Author: matias9927 <matias@udel.edu> Committer: Coleen Phillimore <coleenp@openjdk.org> Date: 2021-09-10 01:05:37 +0000 URL: https://git.openjdk.java.net/jdk/commit/08f0be8388914901ac40525ed995136ce020f432
10-09-2021