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

Array accesses through null references do not generate exceptions.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.1.4
    • tools
    • sparc
    • solaris_2.6


      allan.jacobs@Eng 1997-10-19

      algol% java -fullversion
      java full version "1.1.4n:1997.10.16"
      algol% setenv CLASSPATH .
      algol% cat X.java

      class Y {
         int [] ai = null;
      }
         
      class X extends Y {
         int [] bi = null;
         static int[] func() { return (int[])null; }
         public static void main(String argv[]) {
            int [] ci = null;
            int m = 0;
            try { int i = func()[m = 7]; }
            catch(Exception e) { System.out.println(e); }
            try { X ox = new X(); int i = ox.ai[m = 7]; }
            catch(Exception e) { System.out.println(e); }
            try { X ox = new X(); int i = ox.bi[m = 7]; }
            catch(Exception e) { System.out.println(e); }
            try { int i = ci[m = 7]; }
            catch(Exception e) { System.out.println(e); }
            try { int i = ((int[])null)[0]; }
            catch(Exception e) { System.out.println(e); }
            System.exit(0);
         }
      }
      algol% javac -d . X.java
      algol% java X
      algol%


      Derived from Modena tests c1512106, c1512107, and c1512211.

            tturnidgsunw Todd Turnidge (Inactive)
            ajacobssunw Allan Jacobs (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: