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

-Xcheck:jni doesn't handle primitive classes

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 1.4.0
    • Fix Version/s: 1.3.1_04
    • Component/s: hotspot
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      04
    • CPU:
      generic, x86
    • OS:
      generic, linux

      Backports

        Description


        Chuck Rasbold got an error while running -Xcheck:jni on ECperf
        which might be incorrect. I had run the JCK tests with -Xcheck:jni
        and believe I saw the same problem (so running the JCKs might
        be a smaller test case).

        The error is "JNI received a class argument that is not a class"
        from isAssignableFrom.

        I believe the problem is in the ValidateClass method of jniCheck.cpp.
        If a primitive class is sent in, the mirror is null. I think there should
        be a check for java_lang_Class::is_primitive in that method.


        Name: rmT116609 Date: 02/20/2002


        FULL PRODUCT VERSION :
        java version "1.4.0"
        Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-b92)
        Java HotSpot(TM) Client VM (build 1.4.0-b92, mixed mode)

        Patched RedHat 7.1 glibc-2.2.4-20 kernel 2.4.7-10

        DESCRIPTION OF THE PROBLEM :

        Class.isAssignableFrom(c);
        where c represents simple type will fail when run with -Xcheck:jni, with
        FATAL ERROR in native method: JNI received a class argument
        that is not a class

        REGRESSION. Last worked in version 1.3.1

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        1. javac test.java
        2. java -Xcheck:jni test

        EXPECTED VERSUS ACTUAL BEHAVIOR :
        That's what happens on 1.3.1

        java -Xcheck:jni test
        Field[0] public int test.intField
        IsAssignable: false
        Field[1] public short test.shortField
        IsAssignable: false
        Field[2] public java.lang.Short test.shortObjectField
        IsAssignable: true


        ERROR MESSAGES/STACK TRACES THAT OCCUR :
        FATAL ERROR in native method: JNI received a class argument that is not a class
        at java.lang.Class.isAssignableFrom(Native Method)
        at test.main(test.java:14)



        This bug can be reproduced always.

        ---------- BEGIN SOURCE ----------
        public class test
        {
        public int intField;
        public short shortField;
        public Short shortObjectField;

        public static void main(String[] params) throws Exception
        {
        java.lang.reflect.Field[] fields = test.class.getFields();
        for(int i=0; i<fields.length; i++)
        {
        System.out.println("Field[" + i + "] " + fields[i]);
        Class c = fields[i].getType();
        System.out.println("IsAssignable: " + Object.class.isAssignableFrom(c));
        }

        }
        }
        ---------- END SOURCE ----------
        (Review ID: 139924)
        ======================================================================

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  foliversunw Fred Oliver (Inactive)
                  Reporter:
                  jloizeausunw Jane Loizeaux (Inactive)
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  0 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Imported:
                    Indexed: