< prev index next >

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

Print this page
*** 1,7 ***
  /*
!  * Copyright (c) 1996, 2020, 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
--- 1,7 ---
  /*
!  * Copyright (c) 1996, 2024, 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

*** 23,21 ***
   * questions.
   */
  
  package java.lang.reflect;
  
  import java.util.StringJoiner;
  
  /**
   * The Modifier class provides {@code static} methods and
!  * constants to decode class and member access modifiers.  The sets of
!  * modifiers are represented as integers with distinct bit positions
   * representing different modifiers.  The values for the constants
   * representing the modifiers are taken from the tables in sections
   * {@jvms 4.1}, {@jvms 4.4}, {@jvms 4.5}, and {@jvms 4.7} of
   * <cite>The Java Virtual Machine Specification</cite>.
   *
   * @see Class#getModifiers()
   * @see Member#getModifiers()
   *
   * @author Nakul Saraiya
   * @author Kenneth Russell
--- 23,26 ---
   * questions.
   */
  
  package java.lang.reflect;
  
+ import jdk.internal.javac.PreviewFeature;
+ 
  import java.util.StringJoiner;
  
  /**
   * The Modifier class provides {@code static} methods and
!  * constants to decode class and member access modifiers.
!  * The {@link AccessFlag} class should be used instead of this class.
+  * The sets of modifiers are represented as integers with non-distinct bit positions
   * representing different modifiers.  The values for the constants
   * representing the modifiers are taken from the tables in sections
   * {@jvms 4.1}, {@jvms 4.4}, {@jvms 4.5}, and {@jvms 4.7} of
   * <cite>The Java Virtual Machine Specification</cite>.
   *
+  * @see Class#accessFlags()
+  * @see Member#accessFlags()
   * @see Class#getModifiers()
   * @see Member#getModifiers()
   *
   * @author Nakul Saraiya
   * @author Kenneth Russell

*** 112,18 ***
--- 117,36 ---
  
      /**
       * Return {@code true} if the integer argument includes the
       * {@code synchronized} modifier, {@code false} otherwise.
       *
+      * @apiNote {@code isSynchronized} should only be called with the modifiers
+      * of a {@linkplain Method#getModifiers() method}.
+      *
       * @param   mod a set of modifiers
       * @return {@code true} if {@code mod} includes the
       * {@code synchronized} modifier; {@code false} otherwise.
       */
      public static boolean isSynchronized(int mod) {
          return (mod & SYNCHRONIZED) != 0;
      }
  
+     /**
+      * Return {@code true} if the integer argument includes the
+      * {@code identity} modifier, {@code false} otherwise.
+      *
+      * @apiNote {@code isIdentity} should only be called with the modifiers
+      * of a {@linkplain Class#getModifiers() class}.
+      *
+      * @param   mod a set of modifiers
+      * @return {@code true} if {@code mod} includes the
+      * {@code identity} modifier; {@code false} otherwise.
+      */
+     public static boolean isIdentity(int mod) {
+         return (mod & IDENTITY) != 0;
+     }
+ 
      /**
       * Return {@code true} if the integer argument includes the
       * {@code volatile} modifier, {@code false} otherwise.
       *
       * @param   mod a set of modifiers

*** 291,10 ***
--- 314,17 ---
       * modifier.
       * @see AccessFlag#SYNCHRONIZED
       */
      public static final int SYNCHRONIZED     = 0x00000020;
  
+     /**
+      * The {@code int} value representing the {@code ACC_IDENTITY}
+      * modifier.
+      */
+     @PreviewFeature(feature = PreviewFeature.Feature.VALUE_OBJECTS)
+     public static final int IDENTITY         = 0x00000020;
+ 
      /**
       * The {@code int} value representing the {@code volatile}
       * modifier.
       * @see AccessFlag#VOLATILE
       */

*** 368,11 ***
       * @jls 8.1.1 Class Modifiers
       */
      private static final int CLASS_MODIFIERS =
          Modifier.PUBLIC         | Modifier.PROTECTED    | Modifier.PRIVATE |
          Modifier.ABSTRACT       | Modifier.STATIC       | Modifier.FINAL   |
!         Modifier.STRICT;
  
      /**
       * The Java source modifiers that can be applied to an interface.
       * @jls 9.1.1 Interface Modifiers
       */
--- 398,11 ---
       * @jls 8.1.1 Class Modifiers
       */
      private static final int CLASS_MODIFIERS =
          Modifier.PUBLIC         | Modifier.PROTECTED    | Modifier.PRIVATE |
          Modifier.ABSTRACT       | Modifier.STATIC       | Modifier.FINAL   |
!         Modifier.IDENTITY       | Modifier.STRICT;
  
      /**
       * The Java source modifiers that can be applied to an interface.
       * @jls 9.1.1 Interface Modifiers
       */
< prev index next >