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

java.lang.reflect.Method.getModifiers() produces a wrong result

XMLWordPrintable



      Name: dkC59003 Date: 08/20/99



      When running JDK 1.2.2 VM method getModifiers() produces a wrong result
      (see test source below): it does not include NATIVE flag. This does not
      occur with JDK 1.2, 1.3beta1 and HotSpot VMs.

      $ java -version
      java version "1.2.2"
      Classic VM (build JDK-1.2.2-W, native threads, symcjit)
      $ java b4242912
      Modifiers = 1
      Method = public int java.lang.Object.hashCode()

      Whereas for instance:

      $ java -classic -version
      java version "1.3beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3beta-N)
      Classic VM (build 1.3beta-N, native threads, nojit)
      $ java -classic b4242912
      Modifiers = 257
      Method = public native int java.lang.Object.hashCode()


      ----------------------------------------------------------- b4242912.java
      import java.lang.reflect.*;

      public class b4242912 {

          public static void main( String argv[] ) {
      try {
      Class c = Class.forName("java.util.List");
                  Method m = Array.newInstance(c, 1).getClass().getMethod("hashCode",
                                 new Class[]{});
                  System.out.println("Modifiers = " + m.getModifiers());
                  System.out.println("Method = " + m);
      } catch (ClassNotFoundException e) {
      } catch (NoSuchMethodException e) {}
          }
      }

      ======================================================================

            wmaddoxsunw William Maddox (Inactive)
            dkhukhrosunw Dmitry Khukhro (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: