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

Compiled code sometimes gets exception types wrong

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P2 P2
    • 1.1
    • 1.0
    • hotspot
    • None
    • beta
    • sparc
    • solaris_2.6
    • Verified

      [I had Rene try this on win32, seems to work there]

      /home/ovrskeek> java -XX:-Inline HelloException2
      new excpetion
      new excpetion
        [... lots more ...]
      new excpetion
      new excpetion
      Exception in thread "main" NewException
              at HelloException2.buildE(HelloException2.java:20)
              at HelloException2.blah(HelloException2.java:11)
              at HelloException2.main(HelloException2.java:7)
        
      What seems to be happening, is that the compiler
      looks at the declared type of e, because it doesn't have
      the real type info available.

      class HelloException2 extends Object {
        static int count = 0;
        static Exception e;

        public static void main(String[] args) throws Exception {
          for(int i=0; i<10001; i++)
            blah();
        }

        public static void blah() throws Exception{
          try {
            buildE();
            throw e;
          } catch (NewException e) {
            System.out.println("new excpetion");
          }
        }

        public static void buildE() {
          e = new NewException();
        }
      }

      class NewException extends Exception {
        public NewException() {
          super();
        }

        public NewException(String s) {
          super(s);
        }
      }

            jrose John Rose
            jmcilreesunw James Mcilree (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: