< 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, 2022, 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

*** 27,17 ***
  
  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
--- 27,20 ---
  
  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 ***
--- 115,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

*** 132,10 ***
--- 153,25 ---
       */
      public static boolean isVolatile(int mod) {
          return (mod & VOLATILE) != 0;
      }
  
+     /**
+      * Return {@code true} if the integer argument includes the
+      * {@code value} modifier, {@code false} otherwise.
+      *
+      * @apiNote {@code isValue} 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 value} modifier; {@code false} otherwise.
+      */
+     public static boolean isValue(int mod) {
+         return (mod & VALUE) != 0;
+     }
+ 
      /**
       * Return {@code true} if the integer argument includes the
       * {@code transient} modifier, {@code false} otherwise.
       *
       * @param   mod a set of modifiers

*** 291,10 ***
--- 327,23 ---
       * modifier.
       * @see AccessFlag#SYNCHRONIZED
       */
      public static final int SYNCHRONIZED     = 0x00000020;
  
+     /**
+      * The {@code int} value representing the {@code ACC_IDENTITY}
+      * modifier.
+      */
+     public static final int IDENTITY         = 0x00000020;
+ 
+     /**
+      * The {@code int} value representing the {@code value}
+      * modifier.
+      * @see AccessFlag#VALUE
+      */
+     public static final int VALUE            = 0x00000040;
+ 
      /**
       * The {@code int} value representing the {@code volatile}
       * modifier.
       * @see AccessFlag#VOLATILE
       */

*** 368,10 ***
--- 417,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.VALUE        |
          Modifier.STRICT;
  
      /**
       * The Java source modifiers that can be applied to an interface.
       * @jls 9.1.1 Interface Modifiers
< prev index next >