< prev index next >

src/java.base/share/classes/java/lang/reflect/AccessibleObject.java

Print this page
@@ -1,7 +1,7 @@
  /*
-  * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved.
+  * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved.
   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   *
   * This code is free software; you can redistribute it and/or modify it
   * under the terms of the GNU General Public License version 2 only, as
   * published by the Free Software Foundation.  Oracle designates this

@@ -32,10 +32,12 @@
  import jdk.internal.access.SharedSecrets;
  import jdk.internal.misc.VM;
  import jdk.internal.reflect.CallerSensitive;
  import jdk.internal.reflect.Reflection;
  import jdk.internal.reflect.ReflectionFactory;
+ import jdk.internal.vm.annotation.AOTRuntimeSetup;
+ import jdk.internal.vm.annotation.AOTSafeClassInitializer;
  
  /**
   * The {@code AccessibleObject} class is the base class for {@code Field},
   * {@code Method}, and {@code Constructor} objects (known as <em>reflected
   * objects</em>). It provides the ability to flag a reflected object as

@@ -70,12 +72,18 @@
   *
   * @spec jni/index.html Java Native Interface Specification
   * @jls 6.6 Access Control
   * @since 1.2
   */
+ @AOTSafeClassInitializer
  public class AccessibleObject implements AnnotatedElement {
      static {
+         runtimeSetup();
+     }
+ 
+     @AOTRuntimeSetup
+     private static void runtimeSetup() {
          // AccessibleObject is initialized early in initPhase1
          SharedSecrets.setJavaLangReflectAccess(new ReflectAccess());
      }
  
      /**
< prev index next >