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

Class.checkMemberAccess throws NPE when calling Class methods via JNI

XMLWordPrintable

    • b154
    • b163
    • x86
    • other
    • Not verified

        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.

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

                Created:
                Updated:
                Resolved: