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

fp.bugs 3395 compiler optimizes away unused var w/ exception sideeffect

XMLWordPrintable

    • sparc
    • solaris_2.5

      >From: ###@###.### (Mike Montwill )
      This does not look like form output to me.


      when running the following code:

      class baseClass {

              public baseClass() {}

      }

      class derivedClass extends baseClass {

              public derivedClass () {}

              public void doSomething () {}

      }


      class testClass {

              public testClass () {

                      baseClass baseVar = new baseClass();
                      derivedClass derivedVar = (derivedClass) baseVar; //******
                      // derivedVar.doSomething();

              }

              static public void main (String argv[]) {

                      testClass t = new testClass();
              }
      }

      through the java interpreter after compiling it with javac
      the program terminates normally even though the starred line
      should throw an exception.

      The exception is only thrown if the following line is uncommented.

      The bug here is that a sideeffect (an exception) is optimized away when
      derivedVar is not utilized.

      Environment:
      Win95, JDK release ver 1.0

      Mike Montwill - ###@###.###


            fyellinsunw Frank Yellin (Inactive)
            bhagen Benjamin Hagen (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: