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

(jni) win32 VM throws ClassFormatError instead of NoClassDefFoundError

XMLWordPrintable

    • generic, x86
    • generic, windows_nt



      Name: ouC59006 Date: 09/01/98


      jdk1.2fcsH/win32 fails to pass jck test
      vm/jni/FindClass/fncl001/fncl00103/fncl00103.html.

      When we try to use FindClass to find a class by invalid name,
      it throws ClassFormatError instead of NoClassDefFoundError.
      The following example (see sources below) exhibits the problem:

      > java -version
      Classic VM (build JDK-1.2fcs-H, green threads, nojit)
      > java p.fncl00103
      Exception in thread "main" java.lang.ClassFormatError: p\A (Wrong name: p/A)
              at java.lang.ClassLoader.defineClass0(Native Method)
              at java.lang.ClassLoader.defineClass(ClassLoader.java:360)
              at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:84)
              at java.net.URLClassLoader.defineClass(URLClassLoader.java:198)
              at java.net.URLClassLoader.access$1(URLClassLoader.java:166)
              at java.net.URLClassLoader$1.run(URLClassLoader.java:147)
              at java.security.AccessController.doPrivileged(Native Method)
              at java.net.URLClassLoader.findClass(URLClassLoader.java:141)
              at java.lang.ClassLoader.loadClass(ClassLoader.java:250)
              at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:252)
              at java.lang.ClassLoader.loadClass(ClassLoader.java:207)
              at p.fncl00103.n(Native Method)
              at p.fncl00103.main(fncl00103.java:9)
      >

      --------------------- fncl00103.c ---------------------
      #include "jckjni.h"

      JNIEXPORT void JNICALL Java_p_fncl00103_n(JNIEnv *env, jobject obj) {

      char *name = "p\\A";
      /* same effect with "p/a" */

      (*env) -> FindClass(env, name);
      }
      --------------------- fncl00103.java ------------------
      package p;

      class A {}

      public class fncl00103 {
      static native void n();
      public static void main(String argv[]) {
      System.loadLibrary("fncl00103");
      n();
      }
      }
      ======================================================================

            collins Gary Collins (Inactive)
            oulyankisunw Oleg Ulyankin (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: