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

Class.checkMemberAccess throws NPE when calling Class methods via JNI

    Details

    • Subcomponent:
    • Introduced In Build:
      b154
    • Resolved In Build:
      b163
    • CPU:
      x86
    • OS:
      other
    • Verification:
      Not verified

      Backports

        Description

        FULL PRODUCT VERSION :
        java 9-ea
        Java(TM) SE Runtime Environment (build 9-ea+159)
        Java HotSpot(TM) 64-Bit Server VM (build 9-ea+159, mixed mode)

        ADDITIONAL OS VERSION INFORMATION :
        Windows 10 Enterprise

        A DESCRIPTION OF THE PROBLEM :
        I call Class method (e.g. getDeclaredFields) from JNI -- no Java code on thread stack before Class.getDeclaredFields.

        checkMemberAccess in this case always throws NPE:
        java.lang.NullPointerException
        at java.base/java.lang.Class.checkMemberAccess(Unknown Source)
        at java.base/java.lang.Class.getDeclaredFields(Unknown Source)
                <My JNI code>

        Problematic line of code (\java.base\java\lang\Class.java:2774) :
        final ClassLoader ccl = caller.getClassLoader0();

        caller is always null in my case.

        Proposal:
        final ClassLoader ccl = ClassLoader.getClassLoader(caller);


        REGRESSION. Last worked in version 8u121


        REPRODUCIBILITY :
        This bug can be reproduced always.

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  redestad Claes Redestad
                  Reporter:
                  webbuggrp Webbug Group
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  8 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: