Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8218269

Can't reflect into java.lang.reflect.*

XMLWordPrintable

      ADDITIONAL SYSTEM INFORMATION :
      macOS 10.14.2, JDK 12-ea+30 and JDK 13-ea+6

      A DESCRIPTION OF THE PROBLEM :
      When I run the following code on Java 11, it prints "12", whereas if I run the same code on Java 12-ea+30 or Java 13-ea+6, it prints "0":



      import java.lang.reflect.Field;

      public class Test {
          public static void main(String... args) {
              Field[] modifiers = Field.class.getDeclaredFields();
              System.out.println(modifiers.length);
          }
      }



      When I look in the release notes at https://jdk.java.net/12/release-notes, I can't find any reference to a change that would impact this. I've also looked in the "Changes in this build" and "Issues addressed in this build" links for build 30, and couldn't find anything. I've tried to see if I can download a previous version of Java 12-ea to see if the behaviour was the same there, but was unable to find download links for that those.

      Not sure if this is a bug or an intended change that I can't find a source on. (Most likely it's the latter.) My contact at the Quality Outreach program, Rory O'Donnell, suggested that I file an issue here.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run the code on JDK 12 or JDK 13.


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      It prints "12".
      ACTUAL -
      It prints "0".

      ---------- BEGIN SOURCE ----------

      import java.lang.reflect.Field;

      public class Test {
          public static void main(String... args) {
              Field[] modifiers = Field.class.getDeclaredFields();
              System.out.println(modifiers.length);
          }
      }
      ---------- END SOURCE ----------

            pmangal Priyanka Mangal (Inactive)
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: